Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

dynamic reference of form name 2

Status
Not open for further replies.

jordanking

Programmer
Sep 8, 2005
351
Hello,

I have a pop up form that can be opened by a lot of other forms. I have a txt box on the pop up that is updated to the name of the form that opened the pop up. I want to assign the value of a control on the opening form to be equal the value of the same named control on the pop up form when the pop up is closed.

So, how do I dynamically reference the form name from a text box
simplified:
Code:
     Dim frm As Form
     frm.Name = Me.chrForm ''the name of the text box holding the form name
     Forms!frm!intPurchaseTransID = Me.intPurchaseTransID

I have tried a lot of variations of the above.


Has anyone done this

thanks in advance

.....
I'd rather be surfing
 
try
Code:
Forms(me.chrForm.value)!intPurchaseTransID.value  = Me.intPurchaseTransID.value




Greg
"Personally, I am always ready to learn, although I do not always like being taught." - Winston Churchill
 
thanks,

exactly what i needed.

.....
I'd rather be surfing
 
And just as an FYI -

That can be done with controls and fields as well.

Forms(Me.YourTextBox.Value).Controls(Me.YourOtherTextBox.Value).Value = Whatever

or with variables

Forms(strForm).Controls(strCtl).Value = Whatever

or with field

Me(strFieldName).Value = Whatever


Bob Larson
A2K,A2K3,A2K7,SQL Server 2000/2005,Crystal Reports 10/XI,VB6, WinXP, and Vista
Free Quick Tutorials and Samples:
 
thanks bob, for the extra info

.....
I'd rather be surfing
 
I have tried the following:
Forms(Me.YourTextBox.Value).Controls(Me.YourOtherTextBox.Value).Value = Whatever

to copy data from one form to another, but it is moving the data to the first field in the form, not the control in the form as named.

To be exact, I want to move data from control with the value "Material" in Form1 (note Material is not the field/control name, it is the value in the control) to the field named "Material" in form2. the code is started in a button on form1.

Intuitively, I want have the code:
forms.form2 & Material = me.Material

I used the code from this post:
forms(form2).controls(material).value = me.material
this is the one that is moving data to the first field on the form, not the one as named.
 
I used the code from this post:
forms(form2).controls(material).value = me.material
this is the one that is moving data to the first field on the form, not the one as named."

You aren't using it properly -

You have to pass the names as strings (or use string variables), not the objects themselves.

Forms("form2").Controls("Material").Value = Me.Material


Bob Larson
A2K,A2K3,A2K7,SQL Server 2000/2005,Crystal Reports 10/XI,VB6, WinXP, and Vista
Free Quick Tutorials and Samples:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top