select between dates

  • Thread starter Thread starter blackcat
  • Start date Start date
B

blackcat

i am trying to select critiria using the event procedure behind a button
(visual basic/access basic?) i have 3 fields for the user to enter requred
criteria, from release date, to release date and imprint. could someone
please tell me what the code should be to select this, i can filter using one
field but can get it to work using 3 fields.
 
the code i am using for one date is as follows (taken and adjusted from code
that worked for some other selection)

Forms("edit by titles form").Filter = "Releasedate like '*" & Me.TxtFrmPub &
"*'"

but when i try to do as you suggested i get a type mismatch debug error -
code as follows
Forms("edit by titles form").Filter = "Releasedate & Me.TxtFrmPub & " And
"Releasedate & Me.TxtToPub & "

what am i doing wrong please?
 
Using the examples I referred you to previously, you could arrive at
something like this:

Dim strWhere As String
Const conDateFormat = "\#mm\/dd\/yyyy\#"

If IsDate(Me.txtFrmPub) And IsDate(Me.txtToPub) Then
strWhere = "Releasedate Between " & _
Format(Me.txtFrmPub, conDateFormat) & " And " & _
Format(Me.txtToPub, conDateFormat)
With Forms("edit by titles form")
.Filter = strWhere
.FilterOn = True
End With
Else
MsgBox "Enter both dates"
End If
 
Will this also work on a form all ready coded to double click on the Last
Name and that staff member detail project assignment pop up in another form.

What I am trying to do is when the name is double clicked the user has the
option to enter between dates or a start date and the pop up form will
display the staff detailed information in specific time frame.

Thanks
 
You will need some understanding of VBA code to make this work.

Combine the code we just gave you with the examples in the links posted
earlier.
 
thanks again, i'll give that a go

Allen Browne said:
Using the examples I referred you to previously, you could arrive at
something like this:

Dim strWhere As String
Const conDateFormat = "\#mm\/dd\/yyyy\#"

If IsDate(Me.txtFrmPub) And IsDate(Me.txtToPub) Then
strWhere = "Releasedate Between " & _
Format(Me.txtFrmPub, conDateFormat) & " And " & _
Format(Me.txtToPub, conDateFormat)
With Forms("edit by titles form")
.Filter = strWhere
.FilterOn = True
End With
Else
MsgBox "Enter both dates"
End If
 
Back
Top