Swampmeister
New member
- Local time
- Today, 20:22
- Joined
- May 2, 2022
- Messages
- 8
To start this process I have a procedure to generate a set of Customer IDs within a date range; this correctly retrieves the ones needed. I want it then to pass each Customer ID to another Test procedure to generate a report.
The Test procedure needs to open a report for the current CustomerID
How can I do this? I've tried using lngCustID as a criterion for an SQL statement but it fails.
There are posts on the web to say you can't use a recordset parameter as a report's Record Source but there must be a way.
Code:
Private Sub cmdEmailRequested_Click()
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim strSQL As String
Set dbs = CurrentDb
On Error GoTo ErrorHandler
strSQL = "Select DISTINCT CustomerID From qryDebtorsStatement WHERE (ShipDate BETWEEN #" & [Forms]![frmSales]![Start] & "# AND #" & [Forms]![frmSales]![End] & "#)"
Set rst = dbs.OpenRecordset(strSQL)
If rst.RecordCount > 0 Then
rst.MoveFirst
Do
Call Test(rst!CustomerID)
rst.MoveNext
Loop Until rst.EOF
Else
MsgBox "None"
End If
ErrorHandler:
Resume Next
MsgBox "Error #: " & Err.Number & vbCrLf & vbCrLf & Err.Description
End Sub
The Test procedure needs to open a report for the current CustomerID
Code:
Private Sub Test(ByRef lngCustID As Long)
'Use lngCustID as parameter for report's source qryStatement
End Sub
How can I do this? I've tried using lngCustID as a criterion for an SQL statement but it fails.
There are posts on the web to say you can't use a recordset parameter as a report's Record Source but there must be a way.