Time Calculation result not displaying.
The first part works without issue, adding the system time to the active control.
The second part is the issue.
enter image description here
The Debug states: Run-time Error '13': Type Mismatch
When I mouse over the equation (highlighted in yellow), it says the following:
Me.nM03EI = Expected Time In........ (=NULL)
Me.nM03TO = Time Out................ (16:09)
Me.nM03TL = Total Lines............. (50)
6.1 = Expected Lines Per Hour.
your text
“24 = Hours in Day`
The formula works without issue in Excel, just can’t seem to get it to do the same in Access.
2
You compare the Value
(default) property of the control, so try with:
If Screen.ActiveControl.Name = Me!nM03TO.Name Then
Also, xShen is right, you probably need as the first line:
Screen.ActiveControl.Value = Time
or, to round to the minute:
Screen.ActiveControl.Value = TimeValue(Format(Time, "hh:nn"))
Got it sorted! The penny dropped once I used a helper control field. Seems Access is slightly more intuitive when it comes to time calculations as I did not need to divide the equation by 24. ([nm03tl]/6.1)+[nm03to]
is all I needed. Plus, I was trying to be too clever by deriving the answer via VBA when in reality, I just nested the equation in the Control Source of the field [nM03EI] and it worked perfectly. Thanks again for your time guys.