Perform a search through qualities listed in form

C

Crisyina

I need to know how to create a form that will search certain qualities i have
in combo boxes and when i click on a button an other form pops up with a list
of part that have those certain qualities. Any body have any clue on how i
should start this? All i have is a table.

Thank you
 
C

Carl Rapson

Crisyina said:
I need to know how to create a form that will search certain qualities i
have
in combo boxes and when i click on a button an other form pops up with a
list
of part that have those certain qualities. Any body have any clue on how
i
should start this? All i have is a table.

Thank you

On your first form, which should not be bound to any table or query, add the
combo boxes and populate them with as appropriate by setting their Row
Source properties. Create your second form with its Record Source set to a
query based on your table ("SELECT * FROM [my table]" will do). In the Click
event of the command button on the first form, do the following:

- build a string containing the "search qualities" (criteria) from your
combo boxes. This string should look like the WHERE clause of an SQL SELECT
statement, without the word "WHERE". Be sure to include quotes around any
text values in your criteria. Ultimately, your string should come out
looking something like this:

[field1]=123 AND [field2]='xyz' AND [field3]=456

- open the second form with DoCmd.OpenForm, passing the string you built
above in the WhereCondition parameter:

DoCmd.OpenForm "my form",,,strSQL

This should open the second form "filtered" to only show the records that
match your criteria. This procedure is covered frequently in these
newsgroups, so you should be able to search through the newsgroups and find
some examples.


Carl Rapson
 
Top