form/vba date range setting for report

L

Laurie

I have set up a form for users to select criteria for
reports - including required date range. It works fine on
my machine (Win98 and Access 2002).

Transferred to an XP machine the code fails to select the
date range. Single stepping all looks well???

Can anyone help here?

' set up default dates on the form

Private Sub Form_Load()
today = Date
EndDate = CDate(today) 'default end of range
Mid$(today, 1, 2) = "01" 'default start of range
StartDate = CDate(today)
End Sub

' set up filter string
Private Sub OKbutton_Click()
SelectFilter = " [Students].[Date enrolled] > #" &
StartDate & "# And [Students].[Date enrolled]< #" &
EndDate & "# "

End Sub
 
D

Duane Hookom

It isn't good practice to handle dates as if they were strings. Use
DateSerial() if you want to change the year, month, or day of a date value.
For instance if you want the January date of Today, use:
Today = DateSerial(Year(Today), 1, Day(Today))
or
Today = DateAdd("m", Month(Today)-1, Today)
 

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