Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I create a Running Clock on a Form? 1

Status
Not open for further replies.

Kl337

Technical User
May 12, 2004
8
0
0
US
I want to be able to display system time (00:00:00) on a Form, how would i go about doing that, also i want to be able to get total weekly values (we are dealign with a time sheet) per person in the database. I can do daily but i have eyt to figure out weekly... Any and all ideas are greatly appreciated.
 
Put this code on the timer event

Me!lblClock.Caption = Format(Now, "dddd, d mmm yyyy, hh:mm:ss")

create label and name it lblclock.

try this and let me know
 
Sorry for my lack of knowledge but when you say timer event what do you mean?
 
No probs,

right click the form and goto properties. Go to event tab scroll down right at the bottom. U will c a field called on timer in there go to event procedure and u will c on the right side some dots (...). click the and enter the code mentioned above.

I forgot one more thing. when u r in properties as well set the timer to 1000 (scroll down right at the bottom) at the moment it would be 0.

hope this helps
 
I'm using access 2000 (sp3) if that makes a dif. the only things that are available on the event tab are:

onclick
on dblclick
on mouse move
on mouse up
on mouse down

Sorry for the troubles.
 
don't click the form. Click outside the form the dark grey area and u will c more options.
 
hey this is great, is there a way so that it updates automatically (as opposed to having to click on it to update)
 
Kl337 - Did you:

......when u r in properties as well set the timer to 1000 (scroll down right at the bottom) at the moment it would be 0.

When you set the timer interval property to 1000 it should update for you....

Fred


 
hahaa... yea i did that. next question, i got the module for calculating total time but i need to put that number in a table, i have nto been able to figure that out fot the life of me, any ideas? the control source for said total is: =HoursAndMinutes([Time Out]-[Time In]) HoursandMinutes is the part in the module...
 
Hope this helps,
Code:
DoCmd.SetWarnings False
Dim StringVerb As Long
StringVerb = "15"

DoCmd.RunSQL "INSERT INTO YOURTABLE( YOURFIELD) " & " SELECT " & YOURVARIABLE

DoCmd.SetWarnings True

YOURTABLE= the table to insert the record into
YOURFIELD= the field in the table to insert the data at (TimeIn or TimeOut)
YOURVARIABLE= The variable holding the data (Could be the TimeOut or TimeIn Fields on the form or Now() function.)
GOOD LUCK!
 
So Should It look like this?

Option Compare Database

Private Sub totaltime_BeforeUpdate(Cancel As Integer)
DoCmd.SetWarnings False
Dim StringVerb As Long
StringVerb = "15"

DoCmd.RunSQL "INSERT INTO TOTALS( HoursAndMinutes) " & " SELECT " & =HoursAndMinutes([Time Out]-[Time In])

DoCmd.SetWarnings True

End Sub
 
You dont need to declare StringVerb its not used. You only need to declare variables your going to use. I was using it to test the code, so you can remove the stringverb=15 part. I would create and unbound control on the form with the controlsource=[HoursAndMinutes]([TimeOut]-[TimeIn]) and name this unbound textbox TimeDiff. This way you keep the SQL statement simple and its less likely to cause errors. so it would look like this:
Code:
DoCmd.RunSQL "INSERT INTO TOTALS( HoursAndMinutes) " & " SELECT " & me![TimeDiff]
That It, that should work, let me know what you get.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top