Dynamic form name - referring to control

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,
I have a couple of main forms that call the same secondary form. I'm using OpenArgs to find out which main form called the secondary form. I want to update fields on the primary form from the secondary form. I need to refer to a control on my primary form but the name on the secondary form needs to be dynamically generated.
Right now I have something like
Forms!OpenArgs![MYCONTROL] = queryValue
How can I make this work?
Thanks.
 
There are probably a couple of ways of doing this, though I
may have misunderstood what you're after. Try this one.

Add a new text control to your secondary form, call it
txtCaller, do not bind it to any field and set it's visible
property to false.

On both of your primary forms just after they open the
secondary form add a line setting the new control to the
name of the calling form, something like this:

****Untested code

DoCmd.OpenForm "SecondaryFormName",,, etc 'Don't bother with
OpenArgs
Forms![SecondaryFormName].txtCaller = "NameOfCallingForm"

Then you can refer to a control on the calling form as -

Forms(txtcaller).ControlName

--
Nick Coe (UK)
www.alphacos.co.uk

---

"audreybmorin" <[email protected]>
wrote in message
Hi,
I have a couple of main forms that call the same secondary
form. I'm using OpenArgs to find out which main form called
the secondary form. I want to update fields on the primary
form from the secondary form. I need to refer to a control
on my primary form but the name on the secondary form needs
to be dynamically generated.
Right now I have something like
Forms!OpenArgs![MYCONTROL] = queryValue
How can I make this work?
Thanks.
 
Well, it didn't really answer my question, but this line you gave me:
Forms(txtcaller).ControlName

works with

Forms(OpenArgs)![ControlName]

Seems like, as usual, I was having a syntax problem.

so... it did help :-) Thanks...
 
Back
Top