Time?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is there a way to have a control on a form always show
the current time.

What I'd like to have is when a dispatcher has a blank form
ready to input information, the time control is constantly changing
until they click on a button next to the "Time of Call", that should freeze
the time.

When I query a record, it should have the time stamp for that record.

Tom
 
You could do it the way you suggest - forms have a OnTimer event and you can
set the time interval to "1000" so the event fires each second. But....

One of the common strategies is to have one or more date/time fields in your
form's record source, then use a BeforeUpdate event of the entry form (or
one of its controls) to trigger a simple code line like:

Me!MyTimeStampField=Now()

to automatically set the value of that date/time control to the system
date+time.
-Ed
 
You don't need a clock on your form. You most likely already have a visible
clock at the bottom right of your screen. If it's not there, go to where you
set the settings on your taskbar and turn it on. To freeze the time, add a
textbox with a button to your form. Put the following code in the button's
Click event:
Me!NameOfTextBox = Now()


--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
(e-mail address removed)
www.pcdatasheet.com

Over 1000 Access users have come to me for help. My fees are very
reasonable.
 
suggest you add a field to the form's underlying table, and set the data
type to Date/Time. i'll call the field "CallTime". in the form, you can use
this field to essentially "time-stamp" the record. i can think of three
options to do this, hopefully one will suit your specific need.

to automatically time-stamp the record as soon the user begins entering
data, add the following code to the form's BeforeInsert event procedure, as

If Me.NewRecord Then
Me!CallTime = Now
End If

to automatically time-stamp the record immediately before the record is
saved to the table, add the above code to the form's BeforeUpdate event
procedure, instead of the BeforeInsert event.

to allow the *user* to decide exactly when to time-stamp the record, add a
command button to the form (as you originally described), and run the above
code from the button's Click event.
note: if you choose this option, suggest you set "back up" code to run in
case the user forgets to click the command button. add the back up code to
the form's BeforeUpdate event, as

If Me.NewRecord And IsNull(Me!CallTime) Then
Me!CallTime = Now
End If

note that the "Now" function returns the system's current date and time at
the moment the function is called.
since the records are date/time stamped, you can filter for specific time
frames in a query.

hth
 
to allow the *user* to decide exactly when to time-stamp the record, add a
command button to the form (as you originally described), and run the above
code from the button's Click event.

Alternatively (if you can do a bit of user training) put the code in
the bound textbox's DoubleClick event. The user can simply doubleclick
in the textbox to enter the time; saves the visual noise of another
command button.

This is of course not suitable for frequently changing or naive users
- there's nothing obvious about the textbox to prompt you to
doubleclick it!

John W. Vinson[MVP]
 
Or there's are the built-in shortcuts, shared with Excel:
Ctrl-; for date
Ctrl-: for time.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top