Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select Case problem (easy but cannot find answer)

Status
Not open for further replies.

Trowser

IS-IT--Management
Dec 16, 2002
125
0
0
GB
Select Case DBrec![build_weapons]
Case "", 0, Null

how can I get that Select Case to recognise a null field??
 
I dont think you can directly - what about using

Select Case IIf(IsNull(DBrec![build_weapons]), "", DBrec![build_weapons])

Case "",0

cjw
 
#NULL# is a tough issue because you can't evaluate it other than if it's null. Select case is looking for a value and #NULL# data cannot be evaulated to anything other than #NULL#. What you might do is use CASE ELSE and then when the comparison falls through all the other case statements you can catch it by using the standard "if isnull(fieldname) = true then (operation)" evaluation.
 
thanks lads no wonder I was having such a mare trying to get it to work :)

I did do one other thing I changed the DB so that its default value was "" which I could evaluatate for but useful to know that I can't do that.
I will try sonofemidex1100's solution see if that works aswell.

Ok tried it and that works fine aswell
Thanks alot guys to answers
Change DB or use that iffy
 
Of course you can test for it...Select Case DBrec![build_weapons]
Case "", 0, IsNull(DBrec![build_weapons]
 


Based on what you are looking for, try:

Select Case Val(rsADO("test") & vbNullString)

Case 0 'Will catch if field is a NULL, "", or 0

Case Else

End Select

Or,

Select Case rsADO("test") & vbNullString

Case "0", vbNullString 'Will catch if field is a NULL, "", or 0

Case Else

End Select [/b][/i][/u][sub]*******************************************************
General remarks:
If this post contains any suggestions for the use or distribution of code, components or files of any sort, it is still your responsibility to assure that you have the proper license and distribution rights to do so!
 

> Case "", 0, IsNull(DBrec![build_weapons]

??

IsNull() returns True or False. The value of a field with Null does not. [/b][/i][/u][sub]*******************************************************
General remarks:
If this post contains any suggestions for the use or distribution of code, components or files of any sort, it is still your responsibility to assure that you have the proper license and distribution rights to do so!
 

I know exactly! what you mean... [/b][/i][/u][sub]*******************************************************
General remarks:
If this post contains any suggestions for the use or distribution of code, components or files of any sort, it is still your responsibility to assure that you have the proper license and distribution rights to do so!
 
brilliant thanks lads lots of options there to choose from which makes life much easier :)

I now have a combonation of CClints and SonofEmdec's answers each on differant DB's :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top