Find name of main form

  • Thread starter Thread starter Peter Stone
  • Start date Start date
P

Peter Stone

Novice, Access 2003, XP

I want to pass a control name to another application. The control is on a
subform, but I don't know the name of the main form because the subform is in
various mainforms.

E.g. fsubTxt contains txtBox1. How do I find the name of frmMain and then
pass the frmMain!fsubTxt.Form!txtBox1

Thank you
 
You can get the main form's name by using
Screen.ActiveForm.Name

Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
Thank you

Just what I needed.

Can I pass a reference to the control like this?

Screen.ActiveForm.Name!fsubTxt1.Form!txtPub
 
Peter -

I haven't needed to try this, but I think you can declare an object variable
and then set the object to be the control you want.

Dim objControl as object
objControl = Screen.ActiveForm.Name!fsubTxt1.Form!txtPub

Then you can pass the object.

Someone else may have done this?
 
Another way would be to store the ActiveForm.Name in a variable and call it
through the Forms collection...

Dim sForm As String
sForm = Screen.ActiveForm.Name
Debug.Print Forms(sForm).Controls(fsubTxt1).Form.Controls(txtPub).Value


--
Jack Leach
www.tristatemachine.com

"I haven''t failed, I''ve found ten thousand ways that don''t work."
-Thomas Edison (1847-1931)
 
Back
Top