Query Criteria

  • Thread starter Thread starter Rosy Lee
  • Start date Start date
R

Rosy Lee

Hi All

I very new to access and have written a query to find any words that I type from my database column
This is the code I have written

Like "*" & [Forms]![CodeSearch]![Text2] & "*"

Nice and simple!

However, if I am trying to find a code that starts with "c1" it will find every code that has "c1" in the code.
Example: a1c1
What I would like it to do is find all the codes that start with "c1"
Example: c1 and c11 and c12 etc....

Could you please tell me how I should re-write the query above.

Thanks J
 
If the code is always at the start of your field, simply remove the first
wildcard asterisk and the ampersand:

Like [Forms]![CodeSearch]![Text2] & "*"

If the code may be anywhere in the field, presumably it will be preceded by
a space, so try:

Like "*" & [Forms]![CodeSearch]![Text2] & "*"

If it could be either of these cases, place them in successive Criteria rows.

Hope that helps.
Sprinks
 
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Use this (note the single quotes):

Like "'" & Forms!CodeSearch!Text2 & "'"

Don't put the wildcard characters in the code, allow the user to put
them in the Text Box. Then they can enter

c1*

in the TextBox and the code will work as you desire.

The CON part is that you'll have to teach the users about wildcards.
Not that hard - just show how it works while you have them at the
computer.

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQiTfSIechKqOuFEgEQIk7ACgkBM1yn1ovdXIU8/JQEjQD2zGpt0An28i
3JMY6JZfp1SVlYbFNHGNmgjC
=j6+K
-----END PGP SIGNATURE-----
 
Back
Top