Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

populate EndDate based on StartDate parameter 1

Status
Not open for further replies.

topwaya

Technical User
May 4, 2005
150
US
I have a dialog form where users enter a StartDate and EndDate parameter.

Almost always, the StartDate will be the first day of the month and the EndDate will be the last day of the same month.

Is there a way to populate the EndDate to be the last day of the month that is typed into the StartDate?

Thanks for any help!!
 
In the AfterUpdate event procedure of the StartDate control:
Me![EndDate] = DateSerial(Year(Me![StartDate]), 1 + Month(Me![StartDate]), 0)

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thank you very much for the quick response!
Add added
Code:
Me![txtEnd] = DateSerial(Year(Me![txtStart]), 1 + Month(Me![txtStart]), 0)
To the AfterUpdate event procedure in the txtStart control.

But I get an error message that it can't find the macro "Me![txtEnd] = DateSerial(Year(Me![txtStart]), 1 + Month(Me![txtStart]), 0) "

Am I supposed to do something else as well?

Thanks so much!
 
Then On AfterUpdate property should be [Event procedure]
Then click the 3 ellipsis (...)
Write the VBA code between the Private and the End Sub lines.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks so much!!!

I was putting the code in the wrong place - I figured it out, it works like a charm!!!

You guys are just awesome :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top