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!

Is Null problem 1

Status
Not open for further replies.

primerov

Technical User
Aug 16, 2002
160
0
0
BG




I cannot define the Null situation in my code. I need the condition when the quantity in the
field stock is Null.But i cannot do it.I can do it only with <=1 but then it means that
the presence of 1 piece is not taken into account.

If i write
If CLng(DCount("stock", "Products", StrCondition)) = Null Then
Or
If CLng(DCount("stock", "Products", StrCondition)) = 0 Then


Then the code does not function and no message box appears.

If i write
If CLng(DCount("stock", "Products", StrCondition)) < 1 Then
Then the same happens again.

My code works only when i put the following condition:


If CLng(DCount("stock", "Products", StrCondition)) <= 1 Then
MsgBox "Not on stock" ", vbInformation + vbOKOnly

However, if i write <= 1, then if there is 1 piece on stock, the mesage says i have
nothing on stock and the programme stops.
How can i avoid this difficulty ?


 
Have you tried something like this ?
If Nz(DCount("stock", "Products", StrCondition), 0) = 0 Then
BTW, are you sure to want DCount instead of DSum or DLookUp ?

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
You used the Null property false, try it this way..

If IsNull(CLng(DCount("stock", "Products", StrCondition))) Then

that's the proper way to use IsNull

Regards
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top