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!

Set an object on a form using variables

Status
Not open for further replies.

idono

Technical User
Jan 16, 2002
71
US
I have a form that when click is trying to update another form. I have done this in VBA Access but cannot get it to work in VB. Here is an example in VBA:

Forms(nameofform).Controls(nameofcontrol) = variable

I keep getting an error because forms in true VB only has one property - count. Can anyone shed some light on this?

Dugger
 
if you have 2 forms (Form1 and Form2) and each has a textbox (Text1)...

In Form1 you can say...

Form2.Text1 = variable

or the other way around going from Form2 to Form1...

Form1.Text1 = variable

Have Fun, Be Young... Code BASIC
-Josh Stribling
cubee101.gif

 
In VB, you don't need to access your specific form through the forms collections. You can just do it directly. Here is an example assuming that you want to set the caption of the control "command1" on the form "form2":

form2.command1.caption = "Hello"

Give that a try.

Hope that helps!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top