Link to home
Start Free TrialLog in
Avatar of Blacksh
Blacksh

asked on

Date field2 calculate 30 days after the date of date field1

Hello. I am using Microsoft Access 2000. I have two date fields in a form. Datefield1 is any date (usually today's date). I would like date field2 to calculate 30 days from date field1. I am using a form that is connected to a table.
SOLUTION
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Use the ControlSource of the TextBox for field2 to obtain an automatic update whenever field1 changes. If "from field1" means "before field1" then:

=DateAdd("d",-30,[txtNameOfTextBoxOfField1])

However, at months' end - ultimo - you will probably obtain a better result by subtracting a month:


=DateAdd("m",-1,[txtNameOfTextBoxOfField1])

Further, field1 may be empty (Null), thus:

=IIf(IsNull([txtNameOfTextBoxOfField1]),Null,DateAdd("d",-30,[txtNameOfTextBoxOfField1]))

Of course, if "from field1" means "after field1" then remove the minus sign.
/gustav
Avatar of Blacksh
Blacksh

ASKER

Thank you very much.