Getting data from query with criteria like = or Like

R

ReidarT

I have a table with Counties and Cities
I use a form to select the appropriate data.

Table
ID City County
23 Oslo Oslo
46 Oslo
53 Bergen Sogn og Fjordane
67 Trondheim Sør-Trøndelag
87 Trondheim
97 Bergen Sogn og Fjordane
112 Bergen

In the query I use
City County
tblTable tblTable

Like(forms!form!City) Like(forms!Form!County)

The problem is that I only get records from those who have a value
If I select Oslo as city and * as County I only get 1 record, I should have
had 2 records.

reidarT
 
B

Brendan Reynolds

Queries return rows in which the result of the criteria expression evaluates
to True. Comparisons with Null values do not evaluate to True, they evaluate
to Null. Null represents an unknown value. Is an unknown value equal to,
unequal to, like or unlike any other value, known or unknown? The answer is
unknown, i.e., Null.

You could use the NZ function to handle the Null values, e.g. in query
design view, in the Field row, instead of referring to the County field
directly, use an expression such as ...

CountyName:NZ([County],"")

See NZ Function in the help file for details.
 
J

Jeff Boyce

Reidar

If you are actually using the "Like" expression as a criterion in your
query, I don't see the "*" wildcard.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top