I'm a novice trying to learn. I'm getting an error running the following code (Too few parameters. Expected 1). Can you tell me what I'm missing? Please.
On Error GoTo Error_Handler
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim Source As String
Dim SQL As String
Dim MyPath As String
Dim MyFilename As String
MyPath = "M:\MPF\SigninPlus\AwardsAndDecs\AFGCM_Rosters "
Set db = CurrentDb
SQL = "Select Unit_Desc From qryGoodConduct_RIP Group By Unit_Desc"
Set rs = db.OpenRecordset(SQL)
While Not rs.EOF
MyFilename = "AFGCM Roster_" & rs!Unit_Desc & ".pdf"
DoCmd.OpenReport "rptGoodConduct_RIP", acViewPreview, , "Unit_Desc = '" & rs!Unit_Desc.Value & "'"
DoCmd.OutputTo acOutputReport, , acFormatPDF, MyPath & MyFilename, False
DoCmd.Close acReport, "rptGoodConduct_RIP"
rs.MoveNext
Wend
rs.Close
Set rs = Nothing
Set db = Nothing
Error_Handler_Exit:
On Error Resume Next
Exit Sub
Error_Handler:
MsgBox Err.Description
Resume Error_Handler_Exit