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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Macro for derived attribute using dates 2

Status
Not open for further replies.

nellieA

Technical User
Mar 31, 2001
6
GB
How do you programme a macro to use a field start date and a field end date to produce a derived field called duration.
Please advise on field properites.dateValue?
Can this be done using a macro with setvalue and action arguments to the date fields.
 
Hi Nellie A,
On your form in design view, add a text field. Find it's "Control Source" property. Type in:

=[NameOfYourEndDateField]-[NameOfYourStartDateField]

That's all you really need to do to see the difference in days from one to another. You should probably set the fields Locked property to Yes and its Tab Stop to No. This way no one can attempt to change the data (it wouldn't work anyway) or even stop on the field. Hope that does it for you!
Gord
ghubbell@total.net
 
You do not need to use a macro. Add an unbound textbox to your form or report. Then as it's controlsource use the DateDiff() function. You can find more about DateDiff in help. For example, if you want to know the difference in hours between two dates your controlsource property would look something like this:

=DateDiff("h", [FirstDateField], [SecondDateField])
 
Hi ghubbell and Jerry

Thanks for tip.Tried both ways and they work.
I think I caused myself syntax probs by trying to use macros.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top