using Date to filter reports

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

Guest

Well I thought this was going to be easy but....
I want to print out a report for contact birthdays. I have the date in date
fields and put

Me.Filter = "birthDate = " & START_DATE
Me.FilterOn = True

in the open event for the report. I did this for the initial test , thinking
once I had this working I would worry about only looking at the 'month' part
of the dates which I am not really sure how I am going to do that yet either
(START_DATE is set from a text box control linked to a calendar control )

START_DATE contains a DATE type formated short. Could someone please steer
me in the right direction???

THANK!!!
 
first of all working with date can be somewhat tricky...
what you wrote should be instead
Me.Filter = "birthDate = #" & START_DATE & "#"
Second it would be much better having a form where selecting the date you
want to use to filter the recordset, then open the filtering assigning its
recordsource to a SQL statment which already get the records you want by
filternig the data you are working on according to the date you have choosen.
It doesn't matter what format the date has. Access will always manage the
date in code in its whole format. The format you are talking of is just to
decide what you see in the control or in the field of the table. Not what the
date really is ibehind the scene.

Access has built-in funciotn to retrive each part of the date (day, month,
year). Surf the help file in VBE or in Access itself for hints.

Last, i would preffer filtering the data using the whole date instead of
dealing with each of its part.

I hope it helps.

Rocco
 
The following Select SQL will pull all of the data from the employees table
that have a birthday this month. You could replace the Month(Date()) with any
number 1-12
___________________________________________________________________
SELECT tblEmployees.*
FROM tblEmployees
WHERE (((Month([DateofBirth]))=Month(Date())));
___________________________________________________________________
-- Take Care & God Bless
~ SPARKER ~
 
Back
Top