|
 |
access thread: Current Form Name
Message #1 by "Paul Ansell" <paul.ansell@t...> on Thu, 18 Oct 2001 13:14:36
|
|
Sorry to keep on asking for help.
I have a function that is called from several different forms. Part of the
function is to set a property within that form. Rather than hard coding
the form name in the function and then having to create 3 nearly identical
functions, I would like to store the current form name in a variable and
pass it into the function. I know this should be possible but I just can't
work out how I find the name of the form the called the function.
I'm sure it's something very obvious, but I just can't seem to do it.
Any help would be greatly appreciated.
Paul
Message #2 by Crawford Heriot <cheriot@m...> on Thu, 18 Oct 2001 13:22:20 +0100
|
|
Screen.ActiveForm should return the form name of the active form
Regards
Crawford
Analyst Programmer
Message #3 by "Pardee, Roy E" <roy.e.pardee@l...> on Thu, 18 Oct 2001 07:22:09 -0700
|
|
You don't even need to maintain your own variable--there's a global that
does it for you. Dig it:
If Application.CurrentObjectType = acForm Then
Application.Forms(Application.CurrentObjectName).MyProperty = "New
Value"
End If
To set a property called MyProperty equal to the value "New Value" for
whatever form currently has the focus.
HTH,
-Roy
Roy Pardee
Programmer/Analyst
SWFPAC Lockheed Martin IT
Message #4 by Brian Skelton <brian.skelton@b...> on Thu, 18 Oct 2001 18:33:54 +0100
|
|
As an an alternative (especially if a form may call your function when
it isn't active), pass the form itself to your function as a object
variable. You then have access to all the forms properties and methods:
Declare it like this
Public Sub MySub(..., frmToChange As Form,...)
Call it like this
MySub ...,Me,...
Brian
|
|
 |