Dynamic VBA Command Creation (1 Viewer)

SteveClarkson

Registered User.
Local time
Today, 23:05
Joined
Feb 1, 2003
Messages
439
Hello,

I am sure this must be possible, and can't believe I can't find anything on it - I must be using the wrong terminology!

In VBA I would like to use code something like this:

Code:
"Forms!" & Form.Parent.Name & ".Visible=False"

The idea being, that when you click the button this code is on, it will look up the subform parents' name, and set it's "Visible" property to FALSE.

My hope is that I can use this code in a subform which is used in several parent forms - and it will cut down on VBA code somewhat.

Any help much appreciated!
 

SteveClarkson

Registered User.
Local time
Today, 23:05
Joined
Feb 1, 2003
Messages
439
Thanks for your speedy response.

I have just tried that, but I get Runtime error 13 - Type Mismatch :(
 

SteveClarkson

Registered User.
Local time
Today, 23:05
Joined
Feb 1, 2003
Messages
439
Just found that one myself - thank you very much for your help, that works perfectly, using:

Code:
Forms(Me.Parent.Name).Visible = False


Thanks! :D
 

Users who are viewing this thread

Top Bottom