Getting data from query with criteria like = or Like

  • Thread starter Thread starter ReidarT
  • Start date Start date
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
 
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.
 
Reidar

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