Choose dates for a subform

S

Scott B

I am using the following code that I got from Mr. Green's web site to use a
form to choose a date to display all purchases from a particular guest. The
guests are in the form and the purchases and dates are in a subform. I know
thecode works because I am using it to choose a arrival dates in another
form and report, but it does not entail a sub form. Is this possible or am
I using the code for the wrong purpose.

Thanks,
Scott B

Private Sub cmdChooseDate_Click()

Dim strFilter As String
Dim strArrival As String
' Check that the form is open
If SysCmd(acSysCmdGetObjectState, acForm, "frmGuestBill") <>
acObjStateOpen Then
MsgBox "You must open the form first."
Exit Sub
End If
' Build criteria string for Office field
If IsNull(Me.cboArriveDate.Value) Then
strArrival = "Like '*'"
Else
strArrival = "=#" & Me.cboArriveDate.Value & "#"
End If
' WHERE clause for the filter (StayStart is a Date)
strFilter = "Forms![frmGuestBillSubFrm].[StayStart] " & strArrival
' Apply the filter and switch it on
With Forms![frmGuestBill].[frmGuestBillSubFrm]
.Filter = strFilter
.FilterOn = True
End With
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top