Add Date Function

JPR

Registered User.
Local time
Today, 03:06
Joined
Jan 23, 2009
Messages
202
I have created a form on which I have two textboxes with a Date format (mm/dd/yyyy)

Text1 will be used to store a specific date
Text2 should automatically add 1 month to the previous date

I have used the following code to the Default Value property of Text2 but after entering the date in TEXT1, TEXT2 does not update. Thank you for your help.

Code:
=DateAdd("m",1,[TEXT1])
 
add code to the Chage event of Text1:

Private Sub Text1_Change()
Me.Text2 = DateAdd("m", 1, [Text1])
End Sub
 
Perfect. Thank you
 
Default Value only works for NEW records?
 
Since the change event runs for every character you type, it is not appropriate for this purpose. Use the AfterUpdate event. BUT, better still, there is no need to store the calculated value at all. You can easily calculate it in any query you run. Storing calculated values violates normal forms.
 
Default Value only works for NEW records?

Yep, only for new records for which a null would have been there had it not been for the default. Once there is a value in the slot, Access really has no interest in filling in something again and (by doing so) overriding an existing value.
 

Users who are viewing this thread

Back
Top Bottom