Solved Print reports for each day in a given period (1 Viewer)

Momma

Member
Local time
Today, 15:52
Joined
Jan 22, 2022
Messages
114
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
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 00:52
Joined
Feb 28, 2001
Messages
27,122
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.
 

Momma

Member
Local time
Today, 15:52
Joined
Jan 22, 2022
Messages
114
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.
 

Momma

Member
Local time
Today, 15:52
Joined
Jan 22, 2022
Messages
114
Is there another method to do this?
Any help is highly appreciated 🙏
 
Last edited:

Gasman

Enthusiastic Amateur
Local time
Today, 06:52
Joined
Sep 21, 2011
Messages
14,216
Why not just use DAO?
 

Users who are viewing this thread

Top Bottom