Date Ranges

DBL

Registered User.
Local time
Today, 17:58
Joined
Feb 20, 2002
Messages
659
Happy New Year everyone.

After some time off my brain has liquified and I can't think of an answer to this. I have a form with two unbound text fields into which the user has to enter a date range for a report. The report has to run from 01/01 of the specified year to 31/12/ of the specified year. Firstly I want to have the 01/01/ already in so the user just has to enter the year and then once they enter the year they want I want the second text box to autofill with 31/12/ of the same year, ie 01/01/02 and 31/12/02.

Any ideas?

Thanks

D
 
Why not have the two text boxes disabled and locked and a third text box whereby you can put the year in, or select it from a combo box.

in the AfterUpdate of the third box you could put the code:

txtStartDate=DateSerial(txtYear,1,1)
txtEndDate=DateSerial(txtYear,12,31)

Or, if you insist on having two textboxes with the default values 01/01 and 31/12 then again, on the after update of either put

Sub txtStartDate_AfterUpdate()
txtEndDate=DateSerial(Year(txtStartDate),12,31)
End Sub

Sub txtEndDate_AfterUpdate()
txtStartDate=DateSerial(Year(txtEndDate),1,1)
End Sub
 
Last edited:
Excellent, working well. Never thought about that!

Thanks

D
 
Why not use a calendar control to allow the user select the start date, then add on the amount of days required using code in the background?
 
Thanks Paddy. This is for scientists so the easier the better!
 

Users who are viewing this thread

Back
Top Bottom