Using Date Features to create Form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello all;

I am working on a form that has two text boxes that I am setting up to be a
starting date and ending date for trending data. I am at a loss at this point
as to how I would incorporate a search criteria that would enable searching
from two different dates. What I'm curious about is whether a Macro would be
able to create this search, or would I need to use VB coding? Or could I set
up some sort of Query that would complete this task?

Also, if you know how this might also be accomplished, I would like to also
include one of those little calendar Icons that bring up the small calendar
that you can select dates on, and have them used for input into my text
boxes???? any one know how that can be accomplished?

Thanks so Much for your assistance with this.....
 
If what you are asking is how you can include only data that falls between
the two dates in your form, there are a number of ways it can be done. Which
you choose would depend on how you want your form to behave. Probably the
simplest way to do this would be to put a "SEARCH" command button you your
form that would filter the recordset based on the dates. The code in the
Click event of the command button would look something like this (untested
air code):

Private Sub cmdSearch_Click()
Dim strFilter As String

If IsDate(Me.txtBeginDate) And IsDate(Me.txtEndDate) Then
strFilter = "BETWEEN #" & Me.txtBeginDate & "# And #" &
Me.txtEndDate & "#"
ElseIf IsDate(Me.txtBeginDate) And Not IsDate(Me.txtEndDate) Then
strFilter = ">= #" & Me.txtBeginDate & "#"
ElseIf Not IsDate(Me.txtBeginDate) And IsDate(Me.txtEndDate) Then
strFilter = "<= #" & Me.txtEndDate & "#"
End If

If Len(strFilter) = 0 Then 'Not dates were entered, include
everything
Me.FilterOn = False
Else
Me.Filter = "[TableDateField] " & strFilter
Me.FilterOn = True
End If

Me.Requery

As to your calendar question, There are a lot of varieties of them floating
around. Find one you like and use it.
 
You should be able to make a query that checks a field for date (and time)
values between two dates (and times).

For a "little calendar", try the Microsoft Date and Time Picker (the name
might be a bit different from that) also known as the DTPicker.
 
Back
Top