Update time

  • Thread starter Thread starter Melissa
  • Start date Start date
M

Melissa

I just added a date and time field to our startup form
(the rest of the database links off of this form; none of
the tables are accessible). However, I noticed that as
long as I have the database open, the time does not
update. For example, I opened the database at 8:11 this
morning, and, letting it be open in the back, went on
about my work. When I went back into the database (having
never closed it) at 9:45, it still said 8:11. If I close
the database and re-open it, it updates the time.
I also have a time field on other forms and the same
thing is true.
Can I make it so that it updates every 30 seconds or
every minute (or even every 5?) rather than ONLY when the
form is opened?

Thanks!
Melissa
 
Use a timer event on that form to write the current date/time into that
control. The timer interval is in milliseconds...thus, 1000 is one second.
 
Sounds good, can you help me get that working? I'm not an
Access Expert...
(Thanks for all your help in all the places you're
helping me!!)

Melissa
 
Hi melissa!!
To get things started, lets use one of your forms which
you want to have the clock settings done.

In the form load of this form, you need to write the
following line of code:

Me.timeInterval=1000 (for 1 second)

THEN,on the same form, write the following in the
form_Timer event:

txtBox.value= time().

The 'txtbox' represents the text box you wish to asign the
function of time.(Where you will see the time appear).
Do this for all your forms that require a clock/time box.

HTH,
Patrick
 
Okay, I think I got it. Except one thing: the Form Load
part: does it have to be in the code or is it okay as an
expression?

Also, the way I inserted the time box was to go Insert
Date/Time and pick what I wanted. The same box also shows
the date. Will this code screw that up?

Thanks,
Melissa
 
Actually, this isn't working. I can't get the code part
to work. When I put the line below into the form load
CODE, it then gives me this error when I open the form:

"Microsoft Visual Basic
Compile error:
Method or data member not found
OK Help"

And in the code the ".timeInterval" is highlighted.

:( More help please.
Melissa
 
"Microsoft Visual Basic
Compile error:
Method or data member not found
OK Help"

And in the code the ".timeInterval" is highlighted.

tiny typo on Patrick's part: it's TimerInterval.

The other way you can set this is just in the Form's Properties - one
of them, way down the bottom of the list, is the Timer Interval. Just
type 1000 in the property.
 
Woo, typos are okay, I thought it was me being a total
idiot and not understanding instructions.

My timer interval box already has 1000 in it, but it's
still not updating the time. Am I missing something?
 
Woo, typos are okay, I thought it was me being a total
idiot and not understanding instructions.

My timer interval box already has 1000 in it, but it's
still not updating the time. Am I missing something?

Probably; what do you have in the On Timer event?
 
I have the following:

On Load (event procedure):
Private Sub Form_Load()
Me.TimerInterval = 10000
End Sub

On Timer:
=[time].Value=Time()

Timer Interval:
1000

My text box (with date and time) is called "time"
Do I need to change any of the events for the actual text
box, like the "after update" or "on change"??

This is getting a little frustrating. I don't know what
else to try. I'm tempted to take it out completely at
this point...

Thanks,
Melissa
 
On Timer:
=[time].Value=Time()

Timer Interval:
1000

My text box (with date and time) is called "time"
Do I need to change any of the events for the actual text
box, like the "after update" or "on change"??

I'd change the textbox to a Label (unless you really need the value
elsewhere) and rename the control: Time is a reserved word for the
Time() function and Access might get confused. If you call it lblTime
click the ... icon by the On Timer event and use the Code Builder to
edit in:

Private Sub Form_OnTimer() ' or whatever Access gives you
Me!lblTime.Caption = Format(Time, "hh:nn:ss")
End Function

or, if you do need the textbox, again use the code builder and use
instead

Me!txtTime = Time()

between the Sub and End Sub lines.
 
Back
Top