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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IF date in OnExit 2

Status
Not open for further replies.

topwaya

Technical User
May 4, 2005
150
US
Hi,

I'm trying to write an OnExit event procedure so that if the date in the TxtStart field is 01/01 of any year, then the TxtEnd field will automatically show 12/31/ of that year.

Or else, TxtEnd field will automatically show the last day of the month/year for the TxtStart month/year.

I can't figure out how to write it - the code below is wrong - but maybe someone can help?

Code:
Iff(TxtStart=#01/01/AnyYear#,
Me![TxtEnd] = DateSerial(Year(Me![TxtStart]), 11 + Month(Me![TxtStart]), 0),
Me![TxtEnd] = DateSerial(Year(Me![TxtStart]), 1 + Month(Me![TxtStart]), 0)

If TxtStart=1/1/2005 then TxtEnd=12/31/2005
But
If TxtStart=2/1/2005 then TxtEnd=2/28/2005
same for all the other months.

Thanks very much!!
 
Me!TxtEnd = IIf(Format(Me!TxtStart, "mmdd") = "0101", DateSerial(Year(Me!TxtStart), 12, 31), DateSerial(Year(Me!TxtStart), 1 + Month(Me!TxtStart), 0))

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Wow - was I confused ;)
Of course yours works perfectly!!
Thanks VERY MUCH!!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top