null values

pl456

Registered User.
Local time
Today, 03:35
Joined
Jan 31, 2008
Messages
150
I have a piece of code that builds a query passing some variable from combo boxes on a form.
Generally works fine but for some reason when I pass Like”*” it returns all of the records from that field that are not nulls, I was expecting it to list everything.
This is the code I have, any help great appreciated.

If Nz(Me!cbocust) = "" Then
strcust = "Like '*'"
Else:
strcust = "='" & Me!cbocust.Value & "'"
End If

I have a similar peice of code in the same module that works just like this but works fine.
 
You could add "OR Is Null" to the criteria string
 
You could try to add " or is null" in your statement.
 
Thanks, i figured it was Or Is Null thing.
I tried that and it screwed things up because it was altering the query to have Or Is Null on the end thus creating the wrong query.

What I had to do and if anyone knows of a better way was copy the whole Where clause and stick this in the IF statement so when it passes to the main sql definition it creates the OR part as well as the Like part.

Just looks wrong and I am sure a more elegant way exists.
 

Users who are viewing this thread

Back
Top Bottom