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!

default value with afterupdate 1

Status
Not open for further replies.

topwaya

Technical User
May 4, 2005
150
US
Hi,
I have an afterupdate event on a date field that will make the next date field the last day of the month based on the first date field:

afterupdate code
Code:
Private Sub TxtStart_AfterUpdate()
Me![TxtEnd] = DateSerial(Year(Me![TxtStart]), 1 + Month(Me![TxtStart]), 0)
End Sub

Now, I want to have a default value for the first date field, of the first of this month. I use the following code:

Code:
DateAdd("d",-(Day(Date())-1),Date())

However, now the afterupdate event doesn't work. I guess because the first date field is never updated, it is just a default value.

Anyway to get what I want to work?

I want the first date field to default to be the first day of this month, when they tab over to the next field, I want it to default to the last day of the month in the first field.

Any clues??
Thanks very much for any help!
 
when they tab over to the next field, I want it to default to the last day of the month in the first field.

Could you not put the code in the GotFocus event of the second date field? That way when they tab to it, it should update itself?
 
Thank you! Didn't try the GotFocus, although that is a good idea too! The OnExit works like a charm :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top