using Datediff on a form

Ron in NYC

Registered User.
Local time
Today, 10:49
Joined
Mar 4, 2016
Messages
30
I have a form on which I want to put a tool for the data entry staffer that calculates elapsed time after they enter times into 2 unbound text boxes. We don't want that person to put start/end times for each record. We want to enter just the elapsed time so they need to calculate it.

I have two unbound text boxes formatted as medium time.

The first is named "start." The second is named "end."

In a third unbound text box I enter minutes: DateDiff("n",[Start],[End]) the result is "#Name?"

How do I get it to calculate the minutes (I'll convert to hours when I get the result)?
 
You would need to set the value in code in the after update property of [End] . Before you do that though, rename them to txtStart, and txtEnd. as I'm pretty certain that Start and End are reserved names.

Assuming you do that in the after_update event property module put
Code:
If IsNull(Me.txtEnd) OR IsNull(Me.txtStart) Then
   MsgBox"Please Enter An Start and End Value!"
   Me.txtStart.Setfocus
   Exit Sub
End If

Me.txtYourResultUnboundControl = DateDiff("n",Me.txtStart, Me.txtEnd)
 
Start isn't Reserved...but End is!

Ron in NYC said:
In a third unbound text box I enter minutes: DateDiff("n",[Start],[End])
If, by this, you mean that the above, in red, is exactly what you've entered in the Control Source of this Unbound Textbox, in addition to renaming the Controls, you need to precede the Function with the Equal Sign:

=DateDiff("n",[txtStart],[txtEnd])

Linq ;0)>
 

Users who are viewing this thread

Back
Top Bottom