Solved

Referencing Forms elements from custom Controls

Posted on 1998-11-16
2
175 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 2

Accepted Solution

by:
peterwest earned 50 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

705 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