I need to create a command button to print a report in Preview mode using the criteria from a combo box.
The combo box is unbound and holds a list of clients. I need the user to select the client, then when the button is hit the report lists all the records for that client.
I can write a script which prints a single record from a report, which is here:
Expand|Select|Wrap|Line Numbers
- Dim strReportName As String
- Dim strCriteria As String
- If NewRecord Then
- MsgBox "There is no History Report to run. Please select an existing record." _
- , vbInformation, "Invalid Action"
- Exit Sub
- Else
- strReportName = "rptWHistory"
- strCriteria = "[lngRowID]= " & Me![lngRowID]
- 'strCriteria = "[lngRowID]='" & Me![lngRowID] & "'"
- DoCmd.OpenReport strReportName, acViewPreview, , strCriteria
- End If
But how do I modify this to take the value of my combo box cboClient, make it equal to the fieldname Client and then show all the records in my report?
Thanks!