I've created a report that fits on a Legal sheet of paper. I use the code below to "stuff" the data into the report. Unfortunately, I'm limited to 20 columns. Is there a way to print another set of 20 and then a nother set of 20, etc. until I reach the EOF for my record set. I have may users of the database that have more than 20 records and they can't run the report for those records above the first 20.
(I've attached a stripped down version of my database. Only contains the necessary data, queries and report.)
(I've attached a stripped down version of my database. Only contains the necessary data, queries and report.)
Code:
Private Sub Report_Open(Cancel As Integer)
On Error GoTo Err_Report_Open
Dim rst As ADODB.Recordset
Dim fld As ADODB.Field
Dim ctl As Control
Dim X As Integer
Set rst = New ADODB.Recordset
rst.Open "[Server NLM Files_Crosstab]", CurrentProject.Connection, adOpenDynamic, adLockOptimistic
With rst
For Each fld In rst.Fields
For Each ctl In Me.Controls
If TypeOf ctl Is TextBox And ctl.Name = X Then
If fld.Name = "NLM Name" Then
X = X - 1
End If
ctl.ControlSource = fld.Name
Exit For
ElseIf TypeOf ctl Is Label And Right(ctl.Name, 2) = X Then
ctl.Caption = fld.Name
End If
Next ctl
X = X + 1
Next fld
End With
Exit_Report_Open:
Exit Sub
Err_Report_Open:
MsgBox Err.Description & " - " & Err.Number
Resume Exit_Report_Open
End Sub
Attachments
Last edited: