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
Solved

Referencing Forms elements from custom Controls

Posted on 1998-11-16
2
168 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 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

808 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