real-time date and time displays

ariel81

Registered User.
Local time
Today, 14:15
Joined
Dec 31, 2006
Messages
75
is there any function in access whereby i can have real-time date and time displays on a form? any sample programs i can find?

thank you.
 
You can create a text field and set it's data source to =Now()
If you want it displayed in a certain way, you can use the Format function for Date & Time.
 
how to make use of the now() function for the time to work as a clock? e.g: instead of showing the time during form load...it works as a clock ( time is running).
 
Here's a thing I use. You'll need a textbox called txtOmega (yeah, I'm a
watch fanatic) and you'll maybe want to add some cosmetics to it, like a
frame around it. For the date, add a textbox called
txtDayRunner.

Goto your form’s property box. Under the Event Tab find Timer Interval and
enter 1000.

Code:
Private Sub Form_Open(Cancel As Integer)
'Displays while waiting for timer to crank up    
    Me.txtOmega = Time
End Sub

Private Sub Form_Timer()
   Me.txtOmega = Time 'Display time
   Me.txtDayRunner = Date 'Display date
End Sub
Good Luck!
 
it doesn't worked...
it displayed saturday,december 30,1899
12:00:00 AM

the time doesn't run...
 
I just copied the code from the post and pasted it into a blank database, set the Timer Interval to 1000 and it runs perfectly, just like it has on other databases for 5 years. Have you done any modification to the code, or tried any formatting to the text boxes? The text boxes txtOmega and txtDayRunner should be unbound. Copy your code and paste it back here.
 
OK, that date/time happens to be the Windows default base time and date. That is day 0 of the Windows calendar. So what has happened is that somehow what you passed it is zero.

I'm wondering if you have a broken reference so that time looks not like a function but instead looks like a (undefined) variable. Which by default for VBA code is 0.

Try Time() instead of just Time.

Also Date() instead of just Date.

If it makes no difference, then something else is broken.
 
my mistake, i created the textbox wrongly...i drew labels insteat of textboxes...thanks...
 
Hi there. This is a dumb question related to this discussion, but how would we integrate the code into our text boxes? It's VBA code, obviously, but would you create a macro for that? Or where should it be put?
 
As was said above, you place two textboxes on you form named txtOmega and txtDayRunner.

From the Design View for your form, goto View - Code and copy and paste in the code

Code:
Private Sub Form_Open(Cancel As Integer)
'Displays while waiting for timer to crank up    
    Me.txtOmega = Time
End Sub

Private Sub Form_Timer()
   Me.txtOmega = Time 'Display time
   Me.txtDayRunner = Date 'Display date
End Sub

Finally, goto your form’s property box. Under the Event Tab find Timer Interval (you have to scroll way down) and enter 1000.

Now you're done!
 
i know this is an old thread, but i found it quite interesting, the clock works great for me but the date is giving me nothing, i have this located in my main switchboard, so there are other codes already in the on open event procedure. and i did take liberties with the text box names, but they do match what i have coded here:
Private Sub Form_Open(Cancel As Integer)
' Minimize the database window and initialize the form.
' Move to the switchboard page that is marked as the default.
Me.Filter = "[ItemNumber] = 0 AND [Argument] = 'Default' "
Me.FilterOn = True
'Displays while waiting for timer to crank up
Me.Clock = Time
End Sub
Private Sub Form_Timer()
Me.Clock = Time 'Display time
Me.Date = Date 'Display date
End Sub
any thoughts?
 
You problem is in this line

Me.Date = Date 'Display date

because you've named a control Date which has confused Access! You should never use Access Reserved words as Control names, and using Date is particularly problematical.
 

Users who are viewing this thread

Back
Top Bottom