If, to store the values in seconds, you use a long integer number column with
a Required property of True (Yes) and a Defaultvalue property of 0, called
SecondsDuration say, in the table you can input and display the value in an
unbound text box, txtDuration say, on a form bound to the table as follows:
1. If the values to be entered are always less than one hours you can set
the input Mask property of the txtDuration control to:
00:00;0;_
Otherwise leave its InputMask property blank so that you can input values of
60 minutes or more. In either case leave its Format property blank.
2. In the txtDuration control's AfterUpdate event procedure put:
Me.SecondsDuration = (Left(Nz(txtDuration, "00:00"), _
InStr(Nz(txtDuration, "00:00"), ":") - 1) * 60) _
+ Right(Nz(txtDuration, "00:00"), 2)
3. In the form's Current event procedure put:
Me.txtDuration = Format(SecondsDuration \ 60, "#00") & _
":" & Format(SecondsDuration Mod 60, "00")
Note that this only works with a form in single form view, not in continuous
form view as the unbound txtDuration would show the same value in all rows in
the latter case. To do it in continuous form view, but you'd need a 'hybrid'
control made up of two superimposed combo boxes, one to edit the values, the
other to display them.
In a report you can use an unbound control with a ControlSource property of:
= Format([SecondsDuration] \ 60, "#00") & ":" & Format([SecondsDuration] Mod
60, "00")
The mathematics on the values should be done on the value of the
SecondsDuration column of course. The results can be converted back to the
minutes:seconds format using the same expression as used in the form's
Current event procedure above.
Ken Sheridan
Stafford, England