filter dates and have date range in form

G

Guest

Hi all,
i faced another problem again in access :(
i have previously create a unbound textbox form to filter the subform, with
the help of this forum.
But i was unable to create a range for the dates.
The extracted code is as follows:

Dim strFilter As String
Dim bolAnd As Boolean
bolAnd = False
strFilter = ""
If Len(Me.txtOrigin.Value) > 0 Then
If bolAnd Then
strFilter = strFilter & " and "
End If
strFilter = strFilter & " Origin Like '*" & Me.txtOrigin.Value & "*'"
bolAnd = True
End If
If Len(Me.txtBookingDate.Value) > 0 Then
If bolAnd Then
strFilter = strFilter & " and "
End If
strFilter = strFilter & " [Booking Date] Like '*" &
Me.txtBookingDate.Value & "*'"
bolAnd = True
End If
With Me.[Daily_Report_subform].Form
If .Dirty Then
.Dirty = False
End If
If strFilter = "" Then
.FilterOn = False 'Nothing entered: show all records.
Else
.Filter = strFilter
.FilterOn = True
End If
End With
End Sub

Code ends
How can i make a range for the "booking date", with a start date and end
date to allow user to keyed in, in order to filter the records in the
subform??? i did try those mention in this forum but i keep getting error or
missing expression...

The other problem is on the filtered form to report.
The code is created with the help of this forum but i was unable to filter
the date to the report. I think is the format problem, and i did see it in
this forum before but i lost the page could someone pls help with this?
The extracted code is shown as below:

Private Sub Preview_Report_Click()
On Error GoTo Err_Preview_Report_Click

Dim strWhere
strWhere = "1=1 "
If Not IsNull(Me.txtOrigin) Then
strWhere = strWhere & " AND [Origin] = """ & Me.txtOrigin & """"
End If
If Not IsNull(Me.txtBookingDate) Then
strWhere = strWhere & " AND [Booking Date] = """ & Me.txtBookingDate
& """"
End If
DoCmd.OpenReport "Find_Records", acPreview, , strWhere

Exit_Preview_Report_Click:
Exit Sub

Err_Preview_Report_Click:
MsgBox Err.Description
Resume Exit_Preview_Report_Click

End Sub

How do i change the "booking date" to allow the filter to report to be
successful???
Your help will be greatly appreciated!

Thanks
Green
 
G

Guest

Hi,
Just to add on... For the filtered form to report (the 2nd code), how to add
on to have a range for the "booking date" too?
Sorry for the trouble, but pls help...

Thanks
Green
 

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