Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / May 2008

Tip: Looking for answers? Try searching our database.

Buttons for Date Input

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
AccessNubee - 21 May 2008 00:58 GMT
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!
Daniel Pineault - 21 May 2008 03:20 GMT
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
Signature

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.

> DB is A2000 running on Access 2003
>
[quoted text clipped - 21 lines]
>
> Thanks!
AccessNubee - 21 May 2008 05:00 GMT
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.

> AccessNubee,
>
[quoted text clipped - 62 lines]
>>
>> Thanks!
Arvin Meyer [MVP] - 21 May 2008 20:29 GMT
How about using a form to put the current (or any other date) into you
textbox(es)?

http://www.datastrat.com/Download/Calendar2K.zip
Signature

Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

> DB is A2000 running on Access 2003
>
[quoted text clipped - 21 lines]
>
> Thanks!
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.