I have the following code which is supposed to take the selection from a list box and run a report based on that selection. I am have trouble getting the quotation marks right (I think that's my problem). I have tried many different formats. This current one does not give me an error message, but it also gives me a blank report, even though the data is there.
Any help would be appreciated
Thanks
Pat
Private Sub Command2_Click()
On Error GoTo ReportErr
Dim strWhere As String
If ListNames = 0 Then
strWhere = ""
Else
strWhere = "[Lookup] = """ & [ListNames] & """"
End If
DoCmd.OpenReport "rptByLNameSloc", acViewPreview, , strWhere
Exit Sub
ReportErr:
Select Case Err.Number
Case 2501
Exit Sub
Case Else
Dim strMessage As String, strTitle As String
strMessage = "Error " & Err.Number & ", " & Err.Description & "has occurred."
strTitle = "Unexpected Error"
MsgBox strMessage, vbInformation, strTitle
End Select
End Sub
Any help would be appreciated
Thanks
Pat
Private Sub Command2_Click()
On Error GoTo ReportErr
Dim strWhere As String
If ListNames = 0 Then
strWhere = ""
Else
strWhere = "[Lookup] = """ & [ListNames] & """"
End If
DoCmd.OpenReport "rptByLNameSloc", acViewPreview, , strWhere
Exit Sub
ReportErr:
Select Case Err.Number
Case 2501
Exit Sub
Case Else
Dim strMessage As String, strTitle As String
strMessage = "Error " & Err.Number & ", " & Err.Description & "has occurred."
strTitle = "Unexpected Error"
MsgBox strMessage, vbInformation, strTitle
End Select
End Sub