Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Referencing Forms elements from custom Controls

Posted on 1998-11-16
2
Medium Priority
?
189 Views
Last Modified: 2010-05-03
OK.. I'm new in VB... I need a way to say make a text box display a message (from a database or any source for that matter)by clicking on a command button from within my own control... So how do you access the command button on the form from the custom control... thanx
0
Comment
Question by:lamer2
2 Comments
 
LVL 2

Accepted Solution

by:
peterwest earned 150 total points
ID: 1445163
Hi,

Ok then - you could use the ParentControls property of the ActiveX object but this uses an object index to specify which object you want to access; this is obviously a little fiddly - an easier way is like this:

Private Sub Command1_Click()

      UserControl.Parent.Text1.Text = "Hello World"

End Sub


Just as you can prefix a property with an object you can also prefix an object with a form.  In this case we use the Parent property of the UserControl to get a reference to the parent form and then we can modify the textboxes property.

Hope this helps,

Pete

0
 

Author Comment

by:lamer2
ID: 1445164
when i kinda figure it out myself...

I noticed that typing

parent.text1 = "bla bla does the same thing"
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month21 days, 6 hours left to enroll

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question