Buttons for Date Input

A

AccessNubee

DB is A2000 running on Access 2003

I have a main form ( frmOpenReport) with a subform (subReportList) listing
the reports I want to open.
The main form has three fields to input date ranges as report parameters :
[StartDate] [EndDate] [MeetingDate]
The user can enter any date range they need(and this works), but I want to
be able to quickly enter the most common dates used. I want to make some
buttons to quickly fill the boxes with dates as follows:

Button name -StartDate -EndDate
btnYearToDate - 1/1/(current year) - Today's Date
btnSinceLastPayment - (an answer from a Select query ) - Today's Date
btnSinceLastMeeting - (an answer from a Select query will go in the
MeetingDate field) - the others are left blank

After the fields are filled, the user selects a report to run and the report
will use the appropriate date field as a query parameter(which is already
working :)..

Does anyone know of how to fill the dates with code? I know it needs to be
the "OnClick" event. I just don't know how to make it work. If you know of
an example on the net somewhere just point me in the right direction. :)

Thanks!
 
D

Daniel Pineault

AccessNubee,

Button name -StartDate -EndDate
btnYearToDate - 1/1/(current year) - Today's Date
btnSinceLastPayment - (an answer from a Select query ) - Today's Date
btnSinceLastMeeting - (an answer from a Select query will go in the
MeetingDate field) - the others are left blank


(current year) = year(date())
Today's Date = date()

Using the onclick event you would pass the value in a fashion similar to

Me.FormControlName = Date()

Where FormControlName is the name of the Text Box that you wish to pass the
value to.

So if you wished to pass the YeartoDate value to your 'StartDate' then you'd
code it like:
Me.StartDate = "1/1/" & year(date())

A couple other function you may wish to be aware of for manipulating dates

DateAdd(), DateDiff(), Year(), Month(), Day()

Look in the help for example on their respective usage.

For allowing your user to select a date using a calendar take a look at

http://www.allenbrowne.com/ser-51.html
http://www.lebans.com/monthcalendar.htm
--
Hope this helps,

Daniel Pineault
http://www.cardaconsultants.com/
For Access Tips and Examples: http://www.devhut.com/index.php
Please rate this post using the vote buttons if it was helpful.
 
A

AccessNubee

Excellent, I got the buttons to get the Year to date to work, I also ended
up doing the current year ( 1/1 to 12/31)

My next delima (I've been working on all night...) is to get the results
from a query to populate for either SinceLast...button.
Here's an example of my query to find the last payment:

SELECT Last(NationalDuesPayments.NationalPaymentDate) AS
LastOfNationalPaymentDate
FROM NationalDuesPayments;

How can I have the result go into the StartDate? I would prefer to have the
query in the code.


Daniel Pineault said:
AccessNubee,

Button name -StartDate -EndDate
btnYearToDate - 1/1/(current year) - Today's Date
btnSinceLastPayment - (an answer from a Select query ) - Today's Date
btnSinceLastMeeting - (an answer from a Select query will go in the
MeetingDate field) - the others are left blank


(current year) = year(date())
Today's Date = date()

Using the onclick event you would pass the value in a fashion similar to

Me.FormControlName = Date()

Where FormControlName is the name of the Text Box that you wish to pass
the
value to.

So if you wished to pass the YeartoDate value to your 'StartDate' then
you'd
code it like:
Me.StartDate = "1/1/" & year(date())

A couple other function you may wish to be aware of for manipulating dates

DateAdd(), DateDiff(), Year(), Month(), Day()

Look in the help for example on their respective usage.

For allowing your user to select a date using a calendar take a look at

http://www.allenbrowne.com/ser-51.html
http://www.lebans.com/monthcalendar.htm
--
Hope this helps,

Daniel Pineault
http://www.cardaconsultants.com/
For Access Tips and Examples: http://www.devhut.com/index.php
Please rate this post using the vote buttons if it was helpful.



AccessNubee said:
DB is A2000 running on Access 2003

I have a main form ( frmOpenReport) with a subform (subReportList)
listing
the reports I want to open.
The main form has three fields to input date ranges as report parameters
:
[StartDate] [EndDate] [MeetingDate]
The user can enter any date range they need(and this works), but I want
to
be able to quickly enter the most common dates used. I want to make some
buttons to quickly fill the boxes with dates as follows:

Button name -StartDate -EndDate
btnYearToDate - 1/1/(current year) - Today's Date
btnSinceLastPayment - (an answer from a Select query ) - Today's Date
btnSinceLastMeeting - (an answer from a Select query will go in the
MeetingDate field) - the others are left blank

After the fields are filled, the user selects a report to run and the
report
will use the appropriate date field as a query parameter(which is already
working :)..

Does anyone know of how to fill the dates with code? I know it needs to
be
the "OnClick" event. I just don't know how to make it work. If you know
of
an example on the net somewhere just point me in the right direction. :)

Thanks!
 

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