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

Creating object varaibles for textboxes / labels in a subform.

Status
Not open for further replies.

Donaldson

ISP
May 10, 2005
5
IE
I want to use object variables to set the Text / Caption
properties of unbound textboxes / labels on a subform from code behind the main form.

Can somebody please tell me what is the correct syntax for "Dimming" the varaibles.

Thanks in advance for any help.
 
I don't think you can dim a variable as a property of a textbox, but you can dim a variable as 'Control'.

Dim frm as Form
Dim ctl As Control
Set frm = Me
Set ctl = frm.subFormControlName.Form.Controls("txtPerson")

ctl.Caption = "Person's Name"

But, it'd probably be easier to just work with the control it's self:

Me.subFormControlName.Form.txtPerson.Caption = "Person's Name" "The Key, The Whole Key, and Nothing But The Key, So Help Me Codd!"
 
Thanks for your help, I should clarify that it was the controls that I wanted the object variables to point to.

My reason for wanting to use them is that there are 12 controls listed in each of 5 cases in a select case on one subform, and 8 controls listed in each of 5 cases in a select case on another subform and I felt that using object variables would keep the property assignment lines short and easily readable.

Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top