Date Filters

Neilster

Registered User.
Local time
Today, 00:08
Joined
Jan 19, 2014
Messages
218
Hi guys, I am trying to set a date filter that filters between two dates (Start/End) after I have selected filters from other combo boxes. This is what I Have so far and is a bit of a mess.

I have two text boxes - txtStartDate and txtEndDate

If Nz(Me.txtStartDate.Text) = "" Then
Me.Form.Filter = ""
Me.FilterOn = False


ElseIf Me.cboCity.ListIndex <> -1 Then
Me.Form.Filter = Me.Form.Filter = "NextCallDate Between #" & txtStartDate.Value & "# AND #" & txtEndDate.Value & "#"
Replace(Me.txtStartDate.Text, "'", "''") = & "#"
Me.FilterOn = True


Else
Me.Form.Filter = Me.Form.Filter & " and [StartDate] = "NextCallDate Between #" & txtStartDate.Value & "# AND #" & txtEndDate.Value & "#"
Replace(Me.txtStartDate.Text, "'", "''") & "'"
Me.FilterOn = True

End If


Me.txtStartDate.SetFocus
Me.txtStartDate.SelStart = Len(Me.txtStartDate.Text)

So the idea is I will filter all records by my name then by status then by city and then by start date and end date.


Please can anyone help.?????:banghead::banghead::banghead:
 
Have you composed a query that returns the results you expect?
 
I use this currently if that's what you mean.

Private Sub cboCity_AfterUpdate()

If Nz(Me.cboCity.Text) = "" Then
Me.Form.Filter = ""
Me.FilterOn = False


ElseIf Me.cboCity.ListIndex <> -1 Then
Me.Form.Filter = Me.Form.Filter & " and [City] = '" & _
Replace(Me.cboCity.Text, "'", "''") & "'"
Me.FilterOn = True


Else
Me.Form.Filter = Me.Form.Filter & " and [City] = '" & _
Replace(Me.cboCity.Text, "'", "''") & "'"
Me.FilterOn = True

End If


Me.cboCity.SetFocus
Me.cboCity.SelStart = Len(Me.cboCity.Text)

End Sub

:D:cool:
 

Users who are viewing this thread

Back
Top Bottom