Can't use Me. in a module

  • Thread starter Thread starter Southern at Heart
  • Start date Start date
S

Southern at Heart

I've often used code like this:
Me.Close_Form.Enabled = True

How would I use this if the sub or function is not on the form, but rather
just in a module? The Form name is [Phone_Update].

thanks again.
 
hi,
How would I use this if the sub or function is not on the form, but rather
just in a module? The Form name is [Phone_Update].
Use

Forms![Phone_Update].Form.Close_Form.Enabled = True

or

Forms("Phone_Update").Form.Close_Form.Enabled = True

or more type secure

Dim fr As Form_Phone_Update

Set fr = Forms("Phone_Update")

fr.Close_Form.Enabled = True


mfG
--> stefan <--
 
Pass the form to the sub or function as an argument.

Within your form code:
Call DoThis(Me)

In a general module:
Sub DoThis(frm as Form)
frm.Close_Form.Enabled = True
End Sub

This way you don't need to worry about the name of the form, and if you need
it, you can get it via frm.Name
 
Forms![Phone_Update].Close_Form.Enabled = True


Or

Forms("Phone_Update").Close_Form.Enabled = True

--
John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
..
 
Back
Top