Solved Print reports for each day in a given period

Momma

Member
Local time
Today, 23:09
Joined
Jan 22, 2022
Messages
130
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?

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
 
You need to be in the page where you can see your VBA code. In the menu bar at the top you will see Tools. Click that, then References. You will see a complex dialog box with a list in it. Scroll through that list to find the ADO library. (You'll know it when you see it.) Check the box to the left of that entry and click OK. Recompile.

If that doesn't fix it, get the exact text of the message and show us the line it highlights.
 
You need to be in the page where you can see your VBA code. In the menu bar at the top you will see Tools. Click that, then References. You will see a complex dialog box with a list in it. Scroll through that list to find the ADO library. (You'll know it when you see it.) Check the box to the left of that entry and click OK. Recompile.

If that doesn't fix it, get the exact text of the message and show us the line it highlights.
I'm using Office 365, so it might be different. I googled ADO Library, and it came up with Microsoft ActiveX Data Objects, and there are seven different versions when I go into my References. I do have a Microsoft DAO 3.6 Object Library.
 
Is there another method to do this?
Any help is highly appreciated 🙏
 
Last edited:

Users who are viewing this thread

Back
Top Bottom