View Full Version : query using any criteria


rx_81
03-12-2005, 10:58 AM
I have a 3 tables that are related . There are roughly 8-15 columns in each table.

I need to create a form that has check boxes beside each label (corresponding to each column in the tables) and generate a dynamic query such that the query will only search based on whether the check box is checked or not. The values for the queries (if checked) will be taken from a textbox beside each label.

For example:

1) I have a table of schools containing columns SCHOOL_ID, SCHOOL_NAME, SCHOOL_STREET_ADDRESS, SCHOOL_CITY, SCHOOL_STATE, SCHOOL COUNTRY, SCHOOL_PRINCIPAL and SCHOOL_CONTACT

2)I also have a table containing students who received scholarships containing columns STUDENT_FIRSTNAME, STUDENT_LASTNAME, STUDENT_STREET_ADDRESS, STUDENT_CITY, SCHOOLID, AMOUNT GRANTED

Both of these tables are joined over SCHOOL_ID. I want a form that would allow me to search using any number of columns that i select.

Therefore, all the column names in both tables will be in a form with a checkbox beside them and a textfield. The user can select any number of check boxes and search using that criteria. The user can check off Principal and STUDENT_CITY and type in the values for these in the appropriate text boxes beside each one and it would generate the report based on that.

Is there a simple way of doing this instead of creating a seperate query for all possibilities of check boxes...I have approximately 40 fields in 3 tables to search and I dont' want to have to create a seperate query for all possibilities of what the user can check off and have it run it evaluate what's checked off and run an appropriate query using an IF condition in VBA.

Thanks in advance.

Uncle Gizmo
03-16-2005, 01:56 PM
Excellent compendium of Access 2000 routines from Roger Carlson. (http://www.rogersaccesslibrary.com/download3.asp?SampleName=CreateMultiSelectQuery.md b)

Uncle Gizmo
03-16-2005, 01:59 PM
Opps! Sorry wrong one! its this one.... (http://www.rogersaccesslibrary.com/download3.asp?SampleName=CreateQueries5.mdb)