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

What is the ControlType of the Parent?

Status
Not open for further replies.

FancyPrairie

Programmer
Oct 16, 2001
2,917
0
0
US
I have a textbox on a Page within a TabControl. I want to be able to loop thru the parents until I determine that the parent is the form. How do I know when the parent of the control represents the form?

For example:
Code:
    Dim ctl as control

    debug.print ctl.Parent               'displays "Page1" (Name of the Tab Control page)
    debug.print ctl.Parent.ControlType   '=124 (acPage)

    debug.print ctl.Parent.Parent.Name   'displays "tabCtl" (Name of my Tab Control)
    debug.print ctl.Parent.Parent.ControlType '=123 (acTabCtl)

    debug.print ctl.Parent.Parent.Parent.Name  'displays "Form1" (Name of my form)
    debug.print ctl.Parent.Parent.Parent.ControlType  'Error!! ControlType is not a property of a Form
How do I know that the last one represents a form and not a control?
 
Maybe Type property. You can capture the error and check the error number if it gives one. Only ideas.
 
Thanks for responding.

Trapping the error was the only way I could figure out how to do it, too. I was hoping there was a cleaner way. Guess not.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top