PDA

Click to See Complete Forum and Search --> : MS Access - set current date/time


bigu2fan00
Oct 14th, 2004, 11:28 PM
Hello.

I know this is easy but I'm new to Access and can't figure this out. I would like a text box to display the current date/time and keep the time running, not just a snapshot. Is that possible? I tried to build an event with the expression builder. There, I found the current date/time. Even I knew it's coded as =Now() but that wouldn't work. I tried placing the =Now() on each property of the text box, on focus, on enter, on exit, after update, etc and none seemed to work for me. In the expression builder, I also tried clicking on the text box first then placing the =now() after that but that didn't work either.
What's the easiest way to do this? Can't I just do it through the expression builder?

Thanks.

BrianB
Oct 15th, 2004, 04:05 AM
I don't know if I really like this because my computer already shows the information in the taskbar. Any running process uses system resources. However, for the sake of the exercise :-

The form Events are acccessed via the form Properties. Click the required event as below and choose [Event Procedure] and then click on the dotted button to get to the code module. Copy/Paste the 2 routines as below. It is interesting to see that this ticks away quite happily whilst other things are going on.


'- requires a textbox on the form called "Textbox1"
'------------------------------------------------------
Private Sub Form_Open(Cancel As Integer)
'- set timer interval to 1 second
Me.TimerInterval = 1000
End Sub
'------------------------------------------------------
Private Sub Form_Timer()
Dim MyTime As String
MyTime = Format(Now(), "HH:MM:SS")
Me.TextBox1.Value = MyTime
End Sub
'------------------------------------------------------

bigu2fan00
Oct 15th, 2004, 01:48 PM
Sweet!!! Thanks a lot.