Problem with the date/time field (1 Viewer)

Jonathan Kok

Registered User.
Local time
Today, 08:36
Joined
Jan 27, 2000
Messages
116
I've created a database to track downtime of a machining cell. I've got two fields, stop and start times. The user can enter the times either by hitting a button, in which case it inserts the current date/time, or by typing the time in the field manually.

The trouble I'm having is that it has to track in minutes, and if a user simply types in the current time in the stop/start fields, ie, 2:55 PM, it simply stores the time, and not the date. If the user isn't consistent in using the button vs manual modes, it completely messes up any datediff functions I do (eg. LStopTime = 1/16/2003 12:53:22 PM, LStartTime = 12:56:00 PM, DateDiff("n", LStopTime, LStartTime) = -54197278???)

I imagine I can do some error checking on the BeforeUpdate event, but before I do that, is there any easy way to resolve this?

TIA,
Jonathan
 

ghudson

Registered User.
Local time
Today, 08:36
Joined
Jun 8, 2002
Messages
6,195
Force the user to key the date & time the way you need it by using an Input Mask for that text field. Check the help files for Input Mask for more info and examples.

This input mask should work for you...

00/00/0000\ 00:00:00\ >LL;0;_

Ensure that text box is also formatted for "General Date".

HTH
 

WayneRyan

AWF VIP
Local time
Today, 13:36
Joined
Nov 19, 2002
Messages
7,122
Jonathon,

If the users are inputting dates, then you are going to have
to do some work.

If the entries are going to all be for today you can just have
them enter the time.

dtmEndResult = Date() & " " & Me.txtBoxTime

then you will only have to validate the time field.

If they can enter past/future dates, then you could split it into
two different txtboxes each with their own validation code.

Or, leave it as it is and on the AfterUpdate:
Check it with a DateDiff call and refuse it if its a "nonsense"
result.

good luck,
Wayne
 

Users who are viewing this thread

Top Bottom