Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating A Query With Combo Boxes 1

Status
Not open for further replies.

Lee24

Programmer
Apr 11, 2001
103
GB
Can someone help?

What I Need To Do Is

1, Have a form with 5 combo boxes on it
2, The user can select certain infoprmation from each box or certain boxes
3, With the criteria that they have selected a report will be produced

Tryed But Failed

 
You can generate your query as a SQL string and run it using DoCmd.RunSQL.

A basic example would be:

strSQL = "SELECT * FROM tblFish WHERE tblFish.Type='"
strSQL = strSQL & frmFishInfo.cmbFishType & "'"
DoCmd.RunSQL strSQL
 
Hi Lee,
If you build an unbound form, and place a combobox on it that is getting data from some source, here's the basics:

Your report should be based off of a query. In the query, in the first row of criteria under the appropriate field that would match your data in your combo you would enter something like:

Forms![NameOfYourForm]![NameOfTheComboBox]

Then repeat as required for each combo. In order to avoid errors, each combo should have a default value set (something always there to start) and the report should be activated by a command button on the same form. That should do it! :) Gord
ghubbell@total.net
 
Hi Lee

I think the easiest way to do this is as follows:

1. Let your report be based on a qeuery that selects all the the records that is as if they have selected <all> in all combo boxes.

2. On the form when they click on Ok or whatever create a filter string (As the where clause in a SQL-statement) this should be a global string variable for example strFilter

3. In the reports Open event type the following code:
Me.Filter = strFilter
Me.Filter = On

Regards

Jan Karlsson
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top