Run-time error '2497':
The action or method require a Report Name argument.
I've transcribed the following code straight from a book from which I'm being taught, and to the best of my knowledge, it's been copied character for character:
Expand|Select|Wrap|Line Numbers
- Option Compare Database
- Private strReport As String
- Private Sub cmdPreview_Click()
- Dim strSQL As String
- Dim strWhere As String
- If Not IsNull(txtDistributor) Then
- strWhere = strWhere & " AND DistributorName Like " & "'" & txtDistributor & "*'"
- End If
- If Not IsNull(txtContact) Then
- strWhere = strWhere & " AND ContactName Like " & "'" & txtContact & "*'"
- End If
- If Not IsNull(strWhere) Then
- strSQL = Mid$(strWhere, 6)
- End If
- DoCmd.OpenReport strReport, acViewPreview, , strSQL
- 'Set the option group, combo boxes, and check box back to null
- Clear_Controls:
- grpReports = Null
- txtDistributor = Null
- txtContact = Null
- End Sub
- Private Sub grpReports_AfterUpdate()
- Select Case grpReports
- Case 1
- strReport = "rptVisitorsByDistributor"
- End Select
- End Sub
I'm relatively new to VBA (and programming in general), so any help would be great!