- Open the Form in Design View
- Click on the [End Time] Field
- Click on the Property Sheet icon on the Toolbar to display the Property Sheet of the Field.
- Find the Lost Focus Property and click on it
- Select [Event Procedure] from the drop down control and click on the build (...) button to open the VBA Module.
- A skeletion of a VBA routine will be inserted in the module.
- Write the following line of VBA Code:
me![Trip Time] = [End Time]-[Start Time]
After you enter the [End Time] and the insertion point is moved out of the field the [Trip time] will be calculated and inserted into the [Trip Time] Field. To display the time in hh:nn
format set this format string in the Format Property of the [Trip Time] field.
Internaly the time is stored as a real number like 0.5 for 12:00 noon, the format string formats in the way you want it to be displayed.
If the Date is likely to change between Trip Start and End Times then you must modify the above statement as below:
Me![Trip Time] = ([End Date]+[End Time]) - ([Start Date]+[Start Time])