Auto date update

Rpm1957

Registered User.
Local time
Today, 02:57
Joined
Feb 3, 2012
Messages
19
I have a form with text box for DATE, a combo box for LENGTH OF DEPLOYMENT I.E 4, 6 or 8 weeks and a text box for DUE DATE. how do I get the DUE DATE box to update dependent on the DATE and the LENGTH OF DEPLOYMENT.
I have put this statement in the DUE DATE property CONTROL SOURCE =[DEPLOYMENT DATE]+[LENGTH OF DEPLOYMENT]*7 and it appears to work but I not sure if this is the correct way to do this can anyone help? Thanks
 
If it works; it is generally a good sign.
Personally and I am being pedantic here, I would put some brackets around ([Length of Deployment] * 7)

I use something similar for Age calculated from a Date of Birth

Age.ControlSource =Int((Date()-[DoB])/365.25)

Note the use of the INT to chop off all the Months and Days.
 
Access is frequently very forgiving in how it handles dates, and will currently simply allow adding days to a given date as you've done with

[DEPLOYMENT DATE]+[LENGTH OF DEPLOYMENT]*7

but Access has a number of Date handling Functions, such as DateAdd() and DateDiff(), and really should be used for this kind of thing. Your calcualtion would be done using
Code:
=DateAdd("ww",[LENGTH_OF_DEPLOYMENT],[DEPLOYMENT_DATE])
where ww tells Access that the Interval to be added is week, and [LENGTH_OF_DEPLOYMENT], of course, the number of weeks.

Linq ;0)>
 
Thanks for your help I thought the code was the way to go. Just one question where do I put this code? Is it in the control source for DUE DATE?
 
If you want it be displayed in that Control. Being a Calculated Value, you do not want it to be stored in a Table. You simply re-calculate it as needed, using the same method as given.

Linq ;0)>
 

Users who are viewing this thread

Back
Top Bottom