Frank Freese
asked on
Invalid use of Me. keyword
Experts,
The following code is in a module I call modChangeVisiblty:
Me.LineCode.Locked = False
Me.ScrapTicketDate.Locked = False
Me.ScrapTicketShiftNumber. Locked = False
Me.LineCode.SetFocus
Me.txtBOMDescribed.Visible = False
Me.lblChargedTo.Visible = False
Me.LineCodeID.Visible = False
End Sub
The code worked fine until I placed it is the module and called it
Call mChangeVisiblty and received the Invaalid use of M.e keyword error
The following code is in a module I call modChangeVisiblty:
Me.LineCode.Locked = False
Me.ScrapTicketDate.Locked = False
Me.ScrapTicketShiftNumber.
Me.LineCode.SetFocus
Me.txtBOMDescribed.Visible
Me.lblChargedTo.Visible = False
Me.LineCodeID.Visible = False
End Sub
The code worked fine until I placed it is the module and called it
Call mChangeVisiblty and received the Invaalid use of M.e keyword error
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
cap,
got an error Compile error: Argument not optional at
Call mChangeVisibilty
got an error Compile error: Argument not optional at
Call mChangeVisibilty
ASKER
cap, saw that error...correcting and still working on problem
ASKER
changed to code in mChangeVisibilty and thought Compile eror would go away. still there, at Call mChangeVisibility
With Forms(sForm)
.visible=True
.lblChargedTo.visible=true
.
.
.
End With
End Sub
With Forms(sForm)
.visible=True
.lblChargedTo.visible=true
.
.
.
End With
End Sub
Check out the CodeContextObject, much easier as it referes to the object the code is running from.
Cheers, Andrew
Cheers, Andrew
change way you call the sub to include the name of the form
Call mChangeVisibilty(me.name)
or
Call mChangeVisibilty("Form1") 'where Form1 is the Name of the form
Call mChangeVisibilty(me.name)
or
Call mChangeVisibilty("Form1") 'where Form1 is the Name of the form
ASKER
ok folks....i think i found MY error.
Call changeVisibilty
should have been
Call changeVisibilty(sForm)
Call changeVisibilty
should have been
Call changeVisibilty(sForm)
ASKER
thanks for the information and allowing me the time to understand what i did wrong.
Being a little nitpicky... Me is a shorthand reference to the class a class module is bound to. You often see it
used in Form or Report modules, which are really class modules. If you create your own classes, the Me
keyword when used in those class modules would refer to the class defined in the module.
:)
used in Form or Report modules, which are really class modules. If you create your own classes, the Me
keyword when used in those class modules would refer to the class defined in the module.
:)
matthewspatrick, agreed but explaining the quote below from the Access Help on ME to most users is a waste of time.
"The Me keyword behaves like an implicitly declared variable. It is automatically available to every procedure in a class module. When a class can have more than one instance, Me provides a way to refer to the specific instance of the class where the code is executing. Using Me is particularly useful for passing information about the currently executing instance of a class to a procedure in another module. For example, suppose you have the following procedure in a module:"
Cheers, Andrew
"The Me keyword behaves like an implicitly declared variable. It is automatically available to every procedure in a class module. When a class can have more than one instance, Me provides a way to refer to the specific instance of the class where the code is executing. Using Me is particularly useful for passing information about the currently executing instance of a class to a procedure in another module. For example, suppose you have the following procedure in a module:"
Cheers, Andrew
You need to explicitly specify the form when you put this in generic module not associated with the form.