Me. turns red!

  • Thread starter Thread starter Bob Vance
  • Start date Start date
B

Bob Vance

When ever I type Me. it turns red and I dont get the drop down selection,
also the first letter of any code is changing case to uppercase?
 
Me refers to the current form or report. Code in a standard module doesn't
understand what Me is, nor does code which refers to a different form, and
requires you to fully express it. Instead of:

Me.ControlName

use:

Forms!FormName!ControlName

If that form isn't open, you will still get an error, so you may have to
test for it to be open.
 
Thanks Arvin
Yeah but when start typing it turns red and the list flashes with the
control names and dissapears, never turned red like that before as i am
typing it............Thanks Bob
 
AHA! You probably have a form open that has the timer event that is active.

So when the timer event is triggered, the form event grabs the focus. When
the module you are entering into loses the focus, Access reacts as if you have
clicked out of the module window and you get the behavior you have described.

John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
 
What Arvin said with one exception.

If you are entering code in a standard module that referes to one and only
one form, you might be better of putting that code in the form module. I
say might, because there could be a legitimate reason to hard code a
reference to a specific form, but not likely.

It would most likley be better to pass your prodedure a reference to your
form and use that reference.

Public Function CalculateInfinity(frm As Form, ctl As Control) As Double

If frm.ctl = True Then
......

And to call it:

lngTimeGone = CalculateInfinity(Me, Me.chkOff)
 
John Spencer said:
AHA! You probably have a form open that has the timer event that is active.

So when the timer event is triggered, the form event grabs the focus. When
the module you are entering into loses the focus, Access reacts as if you have
clicked out of the module window and you get the behavior you have described.

Just to follow up on this. I only set the timer event when the user
is running with an MDE. Which is what I always distribute.

Public Function IsMDE() As Boolean

Dim db As DAO.Database

On Error GoTo tagError

Set db = CurrentDb
If db.Properties("MDE") = "T" Then
IsMDE = True
End If
tagNoProperty:
db.Close: Set db = Nothing

On Error GoTo 0
Exit Function

tagError:
Select Case Err.Number
Case 3270 ' Property not found
IsMDE = False
Resume tagNoProperty
Case Else
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in
procedure IsMDE."
End Select

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
 

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

Back
Top