The code i am having trouble with is below, but here is the gist of my problem. I run a label report that pulls the number of labels from a field in a table. This all works without a problem. The issue was when the table has more than one record, the code would only use the number of copies from the first record and apply it to all.
So i created a form that had the code below that runs a macro to clear the table, and then gets each record from my source, appends it to the table, then runs the print routine. The code is failing on the second OpenRecordset which is the append query taking a parameter.
When i run it, i get 'object required' message box. I put a breakpoint in just before "Set rs2 = qdf2.OpenRecordset" and there were no errors, as soon as it gets to this set is where the Object Required message comes up. The value of the parameter shows the proper information, but i cannot figure out what object the OpenRecordset is looking for.
Thanks for any assistance.
******************
Dim db As DAO.Database
Dim db2 As DAO.Database
Dim rs1 As DAO.Recordset
Dim rs2 As Recordset
Dim lotno
Dim qdf As QueryDef
Dim qdf2 As QueryDef
Set db2 = CurrentDb()
Set db = CurrentDb()
Set qdf = db.QueryDefs("Query1-selectQuery")
Set rs1 = qdf.OpenRecordset
Do While Not rs1.EOF
DoCmd.RunMacro "ClearTheTable"
Set lotno = rs1.Fields(3)
Set qdf2 = db2.QueryDefs("Query2-AppendQuery")
Set qdf2.Parameters("[queryPrompt]").Value = rs1.Fields(3)
Set rs2 = qdf2.OpenRecordset
DoCmd.OpenReport "labelReport"
rs1.MoveNext
Loop
rs1.Close
qdf.Close
rs2.Close
qdf2.Close
Set rs1 = Nothing
Set qdf = Nothing
Set rs2 = Nothing
Set qdf2 = Nothing
So i created a form that had the code below that runs a macro to clear the table, and then gets each record from my source, appends it to the table, then runs the print routine. The code is failing on the second OpenRecordset which is the append query taking a parameter.
When i run it, i get 'object required' message box. I put a breakpoint in just before "Set rs2 = qdf2.OpenRecordset" and there were no errors, as soon as it gets to this set is where the Object Required message comes up. The value of the parameter shows the proper information, but i cannot figure out what object the OpenRecordset is looking for.
Thanks for any assistance.
******************
Dim db As DAO.Database
Dim db2 As DAO.Database
Dim rs1 As DAO.Recordset
Dim rs2 As Recordset
Dim lotno
Dim qdf As QueryDef
Dim qdf2 As QueryDef
Set db2 = CurrentDb()
Set db = CurrentDb()
Set qdf = db.QueryDefs("Query1-selectQuery")
Set rs1 = qdf.OpenRecordset
Do While Not rs1.EOF
DoCmd.RunMacro "ClearTheTable"
Set lotno = rs1.Fields(3)
Set qdf2 = db2.QueryDefs("Query2-AppendQuery")
Set qdf2.Parameters("[queryPrompt]").Value = rs1.Fields(3)
Set rs2 = qdf2.OpenRecordset
DoCmd.OpenReport "labelReport"
rs1.MoveNext
Loop
rs1.Close
qdf.Close
rs2.Close
qdf2.Close
Set rs1 = Nothing
Set qdf = Nothing
Set rs2 = Nothing
Set qdf2 = Nothing