We have single page reports that are unique to each state, that are added to our clients annual report. I have a query that will return all of the information that I need for every client that need a report for a specified month. The month needed and a line of text are entered onto a form. A button on the form will run the query. Where I am having a problem is creating the code that will take each line returned by the query and print the report for the correct state. The name of the query is PLSL3, here is the code.
I named the reports the same as the states that are returned by the query. This is my attempt at the code to do the loop.
When I run it I get an runtime error 3061, Too few parameters at the highlighted line. I am unable to see where the error is coming from. Any and all help is appreciated. Thank You
Alan
Senility at its finest
Code:
SELECT DISTINCT [QAMAIN].[STATE], [QAMAIN].[COMPANY], [QAMAIN].[T01DESM], [QAMAIN].[T01FEE], [QAMAIN].[T01COMCD], [QAMAIN].[T01PLSL], [QAMAIN].[T01CONDTM], [QAMAIN].[T01CLINOP], [QAMAIN].[T01CLILOP], [Forms]![TDNR Form]![TDNRDate] AS [Date]
FROM QAMAIN
WHERE ((([QAMAIN].[STATE])<>"CT" And ([QAMAIN].[STATE])<>"MA" And ([QAMAIN].[STATE])<>"NY" And ([QAMAIN].[STATE])<>"FL" And ([QAMAIN].[STATE])<>"GA" And ([QAMAIN].[STATE])<>"PA" And ([QAMAIN].[STATE])<>"TX") And (([QAMAIN].[T01CONDTM])=[Forms]![TDNR Form]![Month]))
ORDER BY [QAMAIN].[STATE], [QAMAIN].[COMPANY]
WITH OWNERACCESS OPTION;
Code:
Public Sub PrintTDNR()
Dim db As Database
Dim rs As DAO.Recordset
Dim varx As Variant
Set db = CurrentDb
[red]Set rs = db.OpenRecordset("PLSL3")[/red]
Do Until rs.EOF = True
varx = DLookup("[STATE]", "PLSL3")
DoCmd.OpenReport varx, acNormal
rs.MoveNext
Loop
Set varx = Nothing
Set rs = Nothing
Set db = Nothing
End Sub
Alan
Senility at its finest