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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA clock on msaccess 2

Status
Not open for further replies.

fergman

Technical User
Oct 19, 2000
91
US
I am attempting to add a clock to an access form, mainly following this thread:

When I compile the module I get this error:
Compile Error:
Invalid use of Me keyword

Here is the code that I am using:
Private Sub Form_Timer()
Me!lblclock.Caption = Format(Now, "dddd, mmm d yyyy, hh:mm:ss AMPM")
End Sub

Private Sub cmdClockStart_Click()
Me.TimerInterval = 1000
End Sub

Private Sub cmdClockEnd_Click()
Me.TimerInterval = 0
End Sub

I appreciate any help you might have.
 
The code must be in the module belonging to the form, invalid use of Me keyword usually means that you have it in an ordinary module.

 
As Remou said, the code has to be in the form's module, not a standard module and not in the various event property boxes (some people do try to place it there.) I just duplicated your scenario, with the code where it should be, and it runs as expected.

If the code is, in fact, in the code window behind the form, then the error message must, I think, refer to something other than this code or the form must be corrupted. If you suspect one the former, in code view you could run Me in the Find function and see if there's a stray Me hanging about in a wrong place. Bits and pieces of stray code do get left behind sometimes!

The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
Guys, you are awesome thanks, my mistake it was on one of the controls, I moved it to the form and it works perfectly.
 
Glad you got it working!

The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top