Re: Guidance on entering and display date & time
- From: RichKorea <RichKorea@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 5 Jun 2008 06:06:01 -0700
"John W. Vinson" wrote:
Dave's absolutely right: do NOT use separate textboxes for the date and time,
it just makes things harder, not simpler.
I wouldn't require the user to type either. Depending on how you are entering
the record, you could either set the Default Value of the field to =Now() to
fill in the date and time the instant a record is started (this would probably
be appropriate for the Call field); or use a single line of easy VBA code in
the textbox's DoubleClick event:
Private Sub txtArrive_DoubleClick()
Me!txtArrive = Now
End Sub
where txtArrive is the name of the textbox bound to the Arrive field. The user
can still overtype it if needed (and if that's permissible...!).
You can easily calculate the time on site etc. using the DateDiff() function
in your report, or in the query upon which you base the report.
--
John W. Vinson [MVP]
Hi John,
Fortunately or unfortunately, I didn't see your follow-up post to Dave
"Klatuu" Hargis' post, so I plowed ahead and created a test database to see
if I could do what I wanted (Dave did say not to try, he just said it would
be difficult). I'm a little leery of Now(), as our service engineers would
be too tempted to just accept the Now() value, rather then entering the
correct date and time. I also like the idea of letting the service engineers
keep their hand on the mouse as much as possible (my form has eight combo
boxes and eight text fields, and then seven date/time fields - management's
crazy about collecting time statistics).
I set up my test database with three date/time fields (general date format),
and then I set up my form with three text boxes (short date format) that
connect to the table, and then I added three more text boxes (medium time
format), using the formula =[Call_Time]-Int([Call_Time]) to figure out the
hours and minutes values. To enter date values, I use the Calendar Control
11.0 that pops up on a Mouse Down event, and to enter hours and minutes, I
added a scroll bar control that's set to 15 minute steps (close enough for
what we need). The scroll bar Update event causes the new time to get added
to the associated date text box, which in turn updates the hours/minutes
display. To wrap it all up, I added a couple of text boxes to show the time
delta results using DateDiff.
If you'd be interested in taking a look at my test database, let me know how
to post it or where to send it.
Thanks,
Rich
.
- References:
- Re: Guidance on entering and display date & time
- From: John W . Vinson
- Re: Guidance on entering and display date & time
- Prev by Date: Re: Highlight current record
- Next by Date: Re: Command Button Question
- Previous by thread: Re: Guidance on entering and display date & time
- Next by thread: Re: Set value of key field in next form
- Index(es):