Link to home
Start Free TrialLog in
Avatar of McGurk1
McGurk1Flag for United States of America

asked on

Get form name using a global variable

I need to be able to capture the name of a form in a global variable.  I saw one thread but it didn't make much sense to me.  Will find it and add it to this thread.  There must be a good way to get the name.
Avatar of McGurk1
McGurk1
Flag of United States of America image

ASKER

ASKER CERTIFIED SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of McGurk1

ASKER

Worked like a dream!!   You have the points.  Can you help me with one more aspect.  How do I use this global variable to reference a control on the form.  It tells me the control is not a part of the form.  However it is and I can see it when I hold the cursor over the variable.  I am using the global variable in a second form.  When I don't use the global variable and just use the formname.control name, it does not error.  I need to use the second form to reference different forms to update them so that is why I need to use a global varialbe for the form name.
You need to CAST that form reference from a generic FORM (which is what OpenForms() returns), to the correct form type that you know it to be.

For instance, if you know that form is of type frmCatalog, then do:

    Dim cat As frmCatalog = CType(GenericFormReferenceHere, frmCatalog)

Now you can use "cat" to get to the controls that are present on the frmCatalog type.
Avatar of McGurk1

ASKER

Idle_Mind,
    Thank you so much.  I wish I could give you some points for this.  It works great!
No problem.

*I wouldn't post in CLOSED questions if I was worried about points!  ;)
Thanks for help idle_mind while I transitioned from work to home. Zone is to you now as I will spend next 3 hours in garden!
Happy gardening!  ...fresh air and sunlight can't be found in a processor!  ;)