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 MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Like & Null troubles in a query

Status
Not open for further replies.

ScubaStevo

Programmer
May 4, 2002
132
AU
I have a query that searches on all fields from a table. I use the Like command to search on each field from a number of textboxes in a form like this:

Like ("*" & [Forms]![QuoteSearch]![CustomerNumber] & "*")

This works fine for all records except for those that are NULL. What is the best approach to rectify this situation? Should I include NULL in each search or make the table have a default value for each field so each field wont be NULL??
 
Instead of
WHERE ... AND [table name].[fieldname] Like ("*" & [Forms]![QuoteSearch]![CustomerNumber] & "*") ...
You may try this:
WHERE ... AND Nz([table name].[fieldname]) Like "*" & [Forms]![QuoteSearch]![CustomerNumber] & "*" ...

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
I use
WHERE ... AND [table name].[fieldname] & "" Like "*" & [Forms]![QuoteSearch]![CustomerNumber] & "*" ...

Duane
MS Access MVP
[green]Ask a great question, get a great answer.[/green]
[red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
[blue]Ask me about my grandson, get a grand answer.[/blue]
 
Yes, work the same way, but one more character to type :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top