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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combo box selection for query

Status
Not open for further replies.

reecejd

Programmer
Feb 13, 2006
3
US
I'm new at Access 03. I have a combobox that is sourced by a table, Rowsource property is:

SELECT Classes.TableID, Classes.ClassID FROM Classes;

The name of my combobox is "ClassCombo".

I'm trying to generate a report based on my combobox selection, but I can't reference the value of the selection. The query tied to my report has the following SQL:

SELECT ClassesForInstructors.ClassID, Instructors.InstructorID, Instructors.FirstName, Instructors.LastName
FROM Instructors INNER JOIN ClassesForInstructors ON Instructors.InstructorID = ClassesForInstructors.InstructorID
WHERE (((ClassesForInstructors.ClassID)="[Forms]![School]![ClassCombo]"));

I'm trying to grab the "ClassCombo" value as input to my query, but it's not working. What am I doing wrong?

Thanks!
 
Get rid of the double-quotes when referencing the combo:
WHERE ClassesForInstructors.ClassID=[Forms]![School]![ClassCombo]

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks, but no luck. I forgot to mention that this query works fine with a textbox input.
 
Have you tried putting the row source as

SELECT ClassesForInstructors.ClassID, Instructors.InstructorID, Instructors.FirstName, Instructors.LastName
FROM Instructors INNER JOIN ClassesForInstructors ON Instructors.InstructorID = ClassesForInstructors.InstructorID

and in your command to open the report

DoCmd.OpenReport "Your Report", acViewPreview, "", "ClassesForInstructors.ClassID=[Forms]![School]![ClassCombo]", acWindowNormal
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top