Hi everybody, I have two reports that I have to print all at once for each day over a six week period.
I've created a temp table with all the dates, ReportDate, tblReportDates.
The reports have a field called CheckListDate, which defines the date of the report.
I'm not good with recordsets yet and I found the following code and it gives me an error "User-defined type not defined" rst As ADODB.Recordset
Can anyone help me to get this right, please?
I've created a temp table with all the dates, ReportDate, tblReportDates.
The reports have a field called CheckListDate, which defines the date of the report.
I'm not good with recordsets yet and I found the following code and it gives me an error "User-defined type not defined" rst As ADODB.Recordset
Can anyone help me to get this right, please?
Code:
Private Sub Command0_Click()
Dim SelectedDate As Date
Dim rst As ADODB.Recordset
Set rst = ADODB.Recordset
rst.Open "Select ReportDate FROM tblReportDates", CurrentProject.Connection, adOpenForwardOnly, adlockreadonly
With rst
If Not .EOF Then
.MoveFirst
Do Until .EOF
SelectedDate = .Fields(0)
DoCmd.OpenReport "rptCheckListDogs", acViewNormal, , "CheckListDate=" & SelectedDate
DoCmd.PrintOut , , , , 1
DoCmd.Close acReport, "rptCheckListDogs"
DoCmd.OpenReport "rptCheckListLitters", acViewNormal, , "CheckListDate=" & SelectedDate
DoCmd.PrintOut , , , , 1
DoCmd.Close acReport, "rptCheckListLitters"
.MoveNext
Loop
End If
.Close
End With