Problem with Calculation from Dates

mixup

Registered User.
Local time
Today, 15:12
Joined
Jul 29, 2005
Messages
34
I have a form with two date fields: "Initiation_date", and "Correction_date". There is a third field called "Duration". I would like to store the values of all three fields in the corresponding table. "Duration" (Long Integer) would be the number of days from "Initiation_Date" to "Correction_Date" if Correction date is there, or to Date() if Correction date is Null.

I can use an unbound text box to get "Duration_cal" using the following as a control source:

=IIf(IsNull([VCor_date]),DateDiff("d",[VInit_date],Date()),DateDiff("d",[VInit_date],[VCor_date]))

But I cannot get that value (No.of Days) in to the "Duration" field. The reason I want to have "Duration" stored as a number is that it is being used in a query for another calculation (total days used for selected records).

Is there a simple way to accomplish this?

Thanks
 
I have figured it out. I had to create a macro with the same expression and put it in the OnCurrent property of the form.
 
You shouldn't store Duration at all, it can be calculated at any time via a calculated control or in a query
 

Users who are viewing this thread

Back
Top Bottom