Realtime clock on a form

F

firecop1

Is there an easy way to put a real time clock onto a form and if so can
anyone explain the process?

Thanks in advance

Andrew J. Brofman
Chief Fire Marshal
Lake Grove, NY
 
F

fredg

Is there an easy way to put a real time clock onto a form and if so can
anyone explain the process?

Thanks in advance

Andrew J. Brofman
Chief Fire Marshal
Lake Grove, NY

Is a Digital clock OK?

Add an unbound text control to the form.
Set it's Format property to Long Time
Name this control "TheTime".

The Long Time format will display the time as
4:17:34 PM

If you wish to include the date as well as the time
6/25/2007 4:19:17 PM
then set the Format property to General date.

Set the Form's TimerInterval property to
1000
Code the Form's Timer event:
Me![TheTime] = Now()

That should be all you need do.

The time will increment in 1 second intervals.
 
M

missinglinq via AccessMonster.com

Hello, again, Chief!

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. If you'd also like to show the date, add a textbox called
txtDayRunner.

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


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
 
F

firecop1

I can only keep thanking you over and over. sAs you can tell I am not a
programmer but I am trying my best to make this work...You are helping me
more than you know.

Thanks for the great advice and I am trying it out now.

Andrew J. Brofman
Chief Fire Marshal
Lake Grove, NY
 
F

firecop1

Yep worked like a charm however I now see "Calculating..." on the bottom bar
of the window and every six seconds the entier window flashes twice.

How would i change the time to military?
 
M

missinglinq via AccessMonster.com

Replace

Me.txtOmega = Time

with

Me.txtOmega = Format(Time, "HH:MM:SS")

to get military time.

As to the flickering, is the Timer Interval set to 1000 as opposed to 100? I
saw this behavior when I was developing this routine, but only at lower Timer
Intervals. Check and if it is at 1000, try increasing it in 100 increments
until it disappears.

I have no idea where the "Calculating..." is coming from! Never heard of such
a thing; maybe someone else here has! What version of Access and what Windows
OP are you using? Exactly where is this showing up?
 
F

firecop1

Yep, I have the timer set for 1000 and will try to bring it up. The
"Calculating..." message comes up along the lower frame of the open database
window. As it alternates with the field type that is currently selected
along the bottom frame of the open databse window.
 
M

missinglinq via AccessMonster.com

I have to admit, I have no idea of what you're speaking. What version of
Access and what version of Windows are you running? Perhaps Access 2003 or
Access 2007?
Yep, I have the timer set for 1000 and will try to bring it up. The
"Calculating..." message comes up along the lower frame of the open database
window. As it alternates with the field type that is currently selected
along the bottom frame of the open databse window.
[quoted text clipped - 18 lines]
Windows
OP are you using? Exactly where is this showing up?
 
F

firecop1

I M running Access 2007
Ok the best way to describe where the "Calculating...." message is it shows
up in the same spot where the status bar text shows up as it alternates with
whatever test is in there for the field that is highlighted.


missinglinq via AccessMonster.com said:
I have to admit, I have no idea of what you're speaking. What version of
Access and what version of Windows are you running? Perhaps Access 2003 or
Access 2007?
Yep, I have the timer set for 1000 and will try to bring it up. The
"Calculating..." message comes up along the lower frame of the open
database
window. As it alternates with the field type that is currently selected
along the bottom frame of the open databse window.
[quoted text clipped - 18 lines]
Windows
OP are you using? Exactly where is this showing up?
 
M

missinglinq via AccessMonster.com

As I said, I've never run into this before, but I post on a number of other
Access forums and will see if I can find out what it's about and if there's a
workaround. I should also add that anytime you post a new question, you need
to be sure and specify that you're using Access 2007! The reason is that
ACC2007 is such a departure from all previous versions that many things that
pertain to it don't pertain to previous versions and vice versa!

Linq
 
M

missinglinq via AccessMonster.com

Hey, Chief!

I've gotten responses from a number of experts about the "Calculating..."
message and no one can explain why the clock code would bring this about. It
does display if complicated calculations are being done, but there are *no*
calculations in the code I provided. You said that the message "alternates
with the field type that is currently selected." What *field type* ? What is
the exact text that appears?

Have a great weekend!

Linq
 
F

firecop1

Well aside from this the code works very well.. I tweaked the timing
settings and it is much smoother now.

Thanks Linq
 
M

missinglinq via AccessMonster.com

HEy, Chief!

I finally heard from an old hand on another site and he suggested trying to
eliminate the problem by writing the time and date to labels instead of text
boxes. If you want to give it a go:

Backup your db file! You really should do this after closing the db anytime
you spend more than 15-20 minutes making changes, and *at least* once a day
if you've used the db!

In Design View

Select txtOmega
Goto Format - Change To
Select Label

Repeat these steps for txtDayRunner

Then, in code, copy and paste this code over your old code for these two subs
(or insert the code in Form_Open if you have stuff in there not pertaining to
the clock hack) :

Private Sub Form_Open(Cancel As Integer)
'Displays while waiting for timer to crank up
Me.txtOmega.Caption = Format(Time, "HH:MM:SS")
Me.txtDayRunner.Caption = Date 'Display date
End Sub
Private Sub Form_Timer()
Me.txtOmega.Caption = Format(Time, "HH:MM:SS") 'Display time
Me.txtDayRunner.Caption = Date 'Display date
End Sub

Now, by default the background color of labels is the same as the color of
the form section they appear on, so you'll probably want to change this to
make it stand out. Right click on the label then use

Fill/Back Color
Font/Fore Color
Special Effect

to change the appearance to something easier on the eye.

Linq
 
J

jahoobob via AccessMonster.com

I've got to ask why? Windows has a clock at the bottom right of the screen
with the exact same time that you will have in your form (as a matter of fact,
I believe the Windows clock is the source of the Access Time.)
I can look right now and tell you my local time is 7:00 PM.
I realize there is a lot of sarcasm in this message but I think sometimes
database designers (Access in particular) try to put too much fluff in the db
just because we can.
 
M

missinglinq via AccessMonster.com

There are people who use "full screen" forms for design purposes and/or to
maximize "real estate." And in this case, as noted above, the OP wants the
time display in military time. I don't know anyway to do that in Regional
Settings.
 
M

missinglinq via AccessMonster.com

I take that back! You actually can set the display for military time!
 
G

Gina Whipp

Just a 'food for thought'. While the database is in military time I don't
wat to look over to my system clock and see military time. I know I had a
case like this.
 
F

firecop1

Sometimes the obvious is not so obvious...
When my Fire Marshals are in their trucks at night and look over at the
screen it is much easier to see the large yellow/black clock I have on the
form than it is to see the microscopic clock on the task bar. So in essence
I am trying to reduce the accident potential. And if your next question is
why dont they use the clock on the truck radio....I work for the
government-there is no radio.

Andy
 
M

missinglinq via AccessMonster.com

Hey,Chief!

Posters here are just like many people in life, they tend to see the world
thru the narrow viewport of their own experiences, never giving thought that
there may be other realities! Unfortunately, this deosn't keep them from
trying to force their views on others! My philosophy over the years has been
to simply ignore posters that only criticize without giving any positive
suggestions!

Linq
 

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

Top