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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Extract a form name from a string

Status
Not open for further replies.

helpneeded

Programmer
Aug 24, 1999
15
GB
How can I extract a form/comboBox name from a string. I pass an openArgs (Forms!frmEnquiries!comboSup) to a form called frmsuppliers. When I close that form I want to pass a value back to Forms!frmEnquiries!comboSup.

Dim MyCombo as ComboBox

Set MyCombo = Me.OpenArgs
MyCombo.Value = 99

The problem is that Me.openArgs is a string and MyCombo is not. I can cheat and do this

Set MyCombo = CVar(Me.openArgs)
MyCombo.value = 99

It works, but there must be a better way.

Thanks in advance to anyone who can help

 
Hi!

Another way to do it is to send only the name of the control in the openargs ("comboSup") and then you can set it this way:

Set MyCombo = Me.Controls(Me.OpenArgs)
MyCombo.Value = 99

Actually, as long as your way is working I don't see how your going to get code any simpler. You already have it working with one command!

hth
Jeff Bridgham
 
Thanks for that, I found an example that looped through the forms collection and returns the index value. I tried to loop through the controls collection of that form but couldn't compare the name value of the openargs against the control name. As you said many ways to crack a nut.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top