S
Scott B
Greetings,
I am taking the advice I received here and trying to use a form to pass the
criteria from a form to a report instead of using a parameter in a query. I
have the report and the form with a combo box and filter button and a cancel
button. I am modifying the code from Martin Green's Office Tips website.
Here is the modified code I am trying to use. I get either no filtering
(all data) or a Data Type Mismatch error depending on whether or not I have
the where clause in it. The code is on the On Click event of the form.
Anyone have any ideas?
Thanks,
Scott B
Private Sub cmdArrival_Click()
Dim strFilter As String
Dim strArrival As String
' Check that the Guest Arrival report is open
If SysCmd(acSysCmdGetObjectState, acReport, "rptGuestArrivals") <>
acObjStateOpen Then
MsgBox "Please open the Guest Arrival report first."
Exit Sub
End If
' Build criteria string for Arrival field
If IsNull(Me.cboArrivalDate.Value) Then
strArrival = "Like '*'"
Else
strArrival = "='" & Me.cboArrivalDate.Value & "'"
End If
' WHERE clause for the filter (StayStart is a Date)
strFilter = "[StayStart]" & strArrival
' Apply the filter and switch it on
With Reports![rptGuestArrivals]
.Filter = strFilter
.FilterOn = True
End With
End Sub
I am taking the advice I received here and trying to use a form to pass the
criteria from a form to a report instead of using a parameter in a query. I
have the report and the form with a combo box and filter button and a cancel
button. I am modifying the code from Martin Green's Office Tips website.
Here is the modified code I am trying to use. I get either no filtering
(all data) or a Data Type Mismatch error depending on whether or not I have
the where clause in it. The code is on the On Click event of the form.
Anyone have any ideas?
Thanks,
Scott B
Private Sub cmdArrival_Click()
Dim strFilter As String
Dim strArrival As String
' Check that the Guest Arrival report is open
If SysCmd(acSysCmdGetObjectState, acReport, "rptGuestArrivals") <>
acObjStateOpen Then
MsgBox "Please open the Guest Arrival report first."
Exit Sub
End If
' Build criteria string for Arrival field
If IsNull(Me.cboArrivalDate.Value) Then
strArrival = "Like '*'"
Else
strArrival = "='" & Me.cboArrivalDate.Value & "'"
End If
' WHERE clause for the filter (StayStart is a Date)
strFilter = "[StayStart]" & strArrival
' Apply the filter and switch it on
With Reports![rptGuestArrivals]
.Filter = strFilter
.FilterOn = True
End With
End Sub