Dispalying a month's worth of records .. off one date

R

roadie.girl

I'm trying to show all of the records for a month on a form.

On "SelectDate" form, I have where the user can select whatever date
they want to. Then on the next form, i want it to display a month's
worth of data ...

so if they select 1/2/2006 - it would display the ENTIRE month of
january.
if they select 4/5/2005 - it would display the ENTIRe month of April of
05.

now the table that the form is based on has a "Date" column in it - so
that is how i am selecting the proper date.

Is there any way to do this? I think i'd need to do it on my underlying
query for the form, but i'm not sure...

thanks in advance for any help!
 
B

Ben

Same here, you can kill me if dunb suggestion:

What if in your query you add a column that shows the month of the date
Month(DateColumn)
And then on your Selectdate form you make an unbound textbox (Invisible)
that shows the month of the selected date... same way as in the query
Then in your query you put a filter linked to the month in the unbound
textbox on your Selectdateform...
 
J

John Griffiths

SELECT *
FROM tblTable tbl
WHERE tbl.DateField
BETWEEN DateSerial(YEAR([SelectDate]), MONTH([SelectDate]), 1 )
AND DateSerial(YEAR([SelectDate]), MONTH([SelectDate])+1,
1 )

Regards John
 
G

Graham Mandeno

The first day of the month containing a given date is calculated by this
expression:
DateSerial( Year(GivenDate), Month(GivenDate), 1)

The last day of the month containing a given date is calculated by:
DateSerial( Year(GivenDate), Month(GivenDate)+1, 0)

When you open a form from code, you can supply a WhereCondition string to
select the records which will be included.

Dim strSelect as String
strSelect= "[YourDateField] between " _
& Format( DateSerial( Year(SelectedDate), _
Month(SelectedDate), 1), "\#mm\/dd\/yyyy\#" ) _
& " and " _
& Format( DateSerial( Year(SelectedDate), _
Month(SelectedDate)+1, 0), "\#mm\/dd\/yyyy\#" )
DoCmd.OpenForm "YourFormName", , , strSelect
 

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