I have the following code in the onclick event of a button.
Code: Select all
Private Sub Open_Report_Click()
Dim strWhere As String
If IsNull(Me.lstRpt) Then
Me.lstRpt.SetFocus
MsgBox "Please select a report, then try again.", vbExclamation
Exit Sub
End If
If Not IsNull(Me.lstLoc) Then
strWhere = "LocationName = " & Chr(34) & Me.lstLoc & Chr(34)
End If
DoCmd.OpenReport ReportName:=Me.lstRpt, View:=acViewPreview, _
WhereCondition:=strWhere
End Sub
Thanks