If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Testing field for null in Select Case statement
I have code something like:
Select case fldMyField Case "All records": ´other code Case "This employee: ´other code Case Null: msgbox "This field can't be empty" Cancel = True End Select The case null statement to test if the field is empty is not working. if isNull(fldMyField) does work Why doesn't the case Null statement work? What would be the best way to do this? Thanks, Lars |
#2
|
|||
|
|||
Testing field for null in Select Case statement
Comparison with Null results in Null, neither True nor False, which is
the reason for the VBA IsNull function or IS NULL in SQL. This should work: Select Case Nz(fldMyField,"") Case "All records": ´other code Case "This employee": ´other code Case "": MsgBox "This field can't be empty" Cancel = True End Select Ken Sheridan Stafford, England On May 5, 8:39 pm, "Lars Brownies" wrote: I have code something like: Select case fldMyField Case "All records": ´other code Case "This employee: ´other code Case Null: msgbox "This field can't be empty" Cancel = True End Select The case null statement to test if the field is empty is not working. if isNull(fldMyField) does work Why doesn't the case Null statement work? What would be the best way to do this? Thanks, Lars |
#3
|
|||
|
|||
Testing field for null in Select Case statement
Thanks Ken!
schreef in bericht ... Comparison with Null results in Null, neither True nor False, which is the reason for the VBA IsNull function or IS NULL in SQL. This should work: Select Case Nz(fldMyField,"") Case "All records": ´other code Case "This employee": ´other code Case "": MsgBox "This field can't be empty" Cancel = True End Select Ken Sheridan Stafford, England On May 5, 8:39 pm, "Lars Brownies" wrote: I have code something like: Select case fldMyField Case "All records": ´other code Case "This employee: ´other code Case Null: msgbox "This field can't be empty" Cancel = True End Select The case null statement to test if the field is empty is not working. if isNull(fldMyField) does work Why doesn't the case Null statement work? What would be the best way to do this? Thanks, Lars |
#4
|
|||
|
|||
Testing field for null in Select Case statement
wat is this
"Lars Brownies" wrote in message ... I have code something like: Select case fldMyField Case "All records": ´other code Case "This employee: ´other code Case Null: msgbox "This field can't be empty" Cancel = True End Select The case null statement to test if the field is empty is not working. if isNull(fldMyField) does work Why doesn't the case Null statement work? What would be the best way to do this? Thanks, Lars |
#5
|
|||
|
|||
Testing field for null in Select Case statement
A Zero-length string, i.e.
"": is not the same thing as Null ! Why not just use Case Else MsgBox "This field can't be empty" Cancel = True Thid includes anything except the stated Cases. -- There's ALWAYS more than one way to skin a cat! Answers/posts based on Access 2000/2003 Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/For...ccess/200905/1 |
#6
|
|||
|
|||
Testing field for null in Select Case statement
(a) Who said it was? I think you need to read the post more
carefully. (b) We can't assume that the list of values is exhaustive. There may well be other legitimate values than those for which the case construct tests. Ken Sheridan Stafford, England On May 5, 10:43 pm, "Linq Adams via AccessMonster.com" u28780@uwe wrote: A Zero-length string, i.e. "": is not the same thing as Null ! Why not just use Case Else MsgBox "This field can't be empty" Cancel = True Thid includes anything except the stated Cases. -- There's ALWAYS more than one way to skin a cat! Answers/posts based on Access 2000/2003 Message posted via AccessMonster.comhttp://www.accessmonster.com/Uwe/Forums.aspx/access/200905/1 |
Thread Tools | |
Display Modes | |
|
|