How to refer to a control created by CreateReportControl?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • inglesp
    New Member
    • Jan 2008
    • 9

    How to refer to a control created by CreateReportControl?

    Does anybody know if it's possible to specify the name of a control created by CreateReportCon trol?

    I have
    Code:
    txtNew = CreateReportControl(...)
    and I can refer to the control as txtNew immediately after it's been created, but this is no use if I want to create several controls in one go and then refer to them later. I've tried
    Code:
    txtNew.name = "newname"
    but then if I try to set
    Code:
    newname.Value = 5
    I get error "Object Required" - it doesn't seem to think that newname refers to the text box.

    Does anybody have any ideas?

    Cheers,
    Peter.
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32633

    #2
    The CreateReportCon trol() function returns a Control object. It's not valid to assign this object to a String variable. This must be stored in an Object (Control) variable. This Control object has a property called .Name which will return the name of any created control for future use. Clearly using the following code will also allow future references.
    Code:
    Dim ctlThis As Control
    
    Set ctlThis = CreateReportControl(...)
    ...
    Call MsgBox(ctlThis.Name)
    ...

    Comment

    Working...