Find all records in a field from a table that contains a key word.

G

Guest

Find all records in a field from a table that contains a key word from a
control on a form.

Table jan05 has records in a field named type that contains values that may
have more than one word. I'd like to run a query that would allow me to find
records deprending on a "key" word I choose from a combo box on my form.

form control [TypeCombo] contains values
Acc
Pho
Cns
Txz
Combined

Some of the records in the table might contain "acc ytd" or "acc hgf" or "hg
acc".

If i choose acc from my userform 'd like my query to still return all
records that contain "acc" somewhere in that record. Also if I select
Combined I just want to return all records.

Here's what I have in my criteria field:

Like IIf([forms]![MainForm]![TypeCombo]="Combined","*",Like "*" &
[forms]![MainForm]![TypeCombo] & "*")

Problem is this isn't working for me I've chosen acc in my combo box and I
know i have records with that text but it's not returning records. Your help
is greatly appreciated.
 
J

John Vinson

If i choose acc from my userform 'd like my query to still return all
records that contain "acc" somewhere in that record. Also if I select
Combined I just want to return all records.

Here's what I have in my criteria field:

Like IIf([forms]![MainForm]![TypeCombo]="Combined","*",Like "*" &
[forms]![MainForm]![TypeCombo] & "*")

Problem is this isn't working for me I've chosen acc in my combo box and I
know i have records with that text but it's not returning records. Your help
is greatly appreciated.

You can't pass an operator such as LIKE in a criterion. Try a
criterion of

LIKE "*" & [Forms]![mainform]![typecombo] & "*" OR
[Forms]![mainform]![typecombo] = "Combined"


John W. Vinson[MVP]
 

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