openrecordset queryname -- too few parameters
Posted on 2011-03-25
I'm using MS Access 2000.
I'm getting a too few parameters error on this openrecordset line:
Set db = CurrentDb()
Set rs = db.OpenRecordset("Q_tags_aisle4", dbOpenDynaset)
Q_tags_aisle4 looks like this:
SELECT DISTINCT Q_tags_aisle1.BRAND, Q_tags_aisle1.Aisle
Q_tags_aisle1 looks like this:
SELECT Left([tbl_line_setup].[RESRV],4) AS Aisle, Left([tbl_line_setup].[BCKUP],4) & " " & Right([tbl_line_setup].[BCKUP],5) AS BCKUP, tbl_line_setup.BRAND, tbl_line_setup.PROGRAM
WHERE (((Left([tbl_line_setup].[RESRV],4))<>"") AND ((tbl_line_setup.PROGRAM)=[Forms]![Main].[txtProgramPass]))
ORDER BY Left([tbl_line_setup].[RESRV],4);
I put a textbox on the form that I set equal to the Program value that the query uses in its criteria.
txtProgramPass.Value = sProgram
The sProgram variable is passing the value correctly and I see it display in the textbox when I step through.
The query runs fine if I just run it myself, but the openrecordset is not working. If I hardcode the criteria into the query then the openrecordset does work, but I obviously can't leave it like that.
What can I try here?