Changing Query Criteria via a form

Neimad

Registered User.
Local time
Today, 13:31
Joined
Jul 11, 2007
Messages
19
Hello,

I want to have a form based on a query, and i want to be able to filter them down. I.E There are 100 people in the database (for example) and I want to be able to reduce them based on certain criteria. Say nationality. So all the records that form are one nationality until ii change it to something else. I would like to be able to do this via a text box or combo box.

Is this possible? Thanks!
 
Add a combobox to your form, say in the footer. Let this combox data source to be either a table containing the nationalities or a query looking up nationalities.

On the combox Click event add code to prepare an SQL statement, along the lines of sqlstr="SELECT * FROM Customers WHERE nationality='" & me.comb0 & "'"

Then add

me.form.recordsource=strsql

me.form.requery

I would also suggest that you add a control or button to put the forms recordsource back to it's original, ie: all records regardless of nationality.
 

Users who are viewing this thread

Back
Top Bottom