View Full Version : Using Combo Box in a Query to run report


iainmid
11-01-2008, 09:02 AM
How do i create a parameter to use a combo box instead of just typing a value in my sql statement to run a report.

I know you can do it from a combo box on a form that the parameter in the sql statement point to but i just want to do this from the sql query itself.

This is the sql statement i have so far but i need the parameter as a combo box to select either Male, Female or Both

SELECT Contacts.*, Contacts.Gender
FROM Contacts
WHERE (((Contacts.Gender)=[Select Gender]));

statsman
11-01-2008, 09:51 AM
How do i create a parameter to use a combo box instead of just typing a value in my sql statement to run a report.

I know you can do it from a combo box on a form that the parameter in the sql statement point to but i just want to do this from the sql query itself.

This is the sql statement i have so far but i need the parameter as a combo box to select either Male, Female or Both

SELECT Contacts.*, Contacts.Gender
FROM Contacts
WHERE (((Contacts.Gender)=[Select Gender]));

Try

SELECT Contacts.*, Contacts.Gender
FROM Contacts
WHERE (((Contacts.Gender)=[Combo1]))

Where Combo1 is the name of the combo box.
Note: the form containing the combo box must be open when you run this.