Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2004
    Posts
    34

    Unanswered: [Resolved] Using varibale to refer to subform control

    Hi all.

    Is it possible to use a variable to refer to the subform control instead of using the name of it?

    So instead of:

    Me!Subform1.Form.RecordSource
    where "subform1" is the name of the subform control

    something like:

    Me!variable.Form.RecordSource
    where variable = "subform1"?
    Last edited by irenicuz; 12-16-05 at 10:31.

  2. #2
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Yup

    Code:
     Dim Var as String
    Var = "TheNameOfMyControl"
    Me(Var).Value = "The Value For My Control"
    Basically - you are referring to the default collection of the form object - the controls collection - so you can reference any item within there as you can (almost) any collection - by index or by name.

    HTH
    Last edited by pootle flump; 12-16-05 at 10:08.
    Testimonial:
    pootle flump
    ur codings are working excelent.

  3. #3
    Join Date
    Feb 2004
    Posts
    34
    i tried something like that, the problem is my form is also a variable:

    Forms(sForm)!<name of control source>.Form.recordsource.

    I would like to somehow also replace the <name of control source> with a variable

  4. #4
    Join Date
    Feb 2004
    Posts
    34
    hehe ok i think i did something wrong, it works now, thanks

    Forms(sForm)(sControl).Form.recordsource.

  5. #5
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Quote Originally Posted by irenicuz
    hehe ok i think i did something wrong, it works now, thanks

    Forms(sForm)(sControl).Form.recordsource.
    Yup - good job - you are just nesting collection retrivals. Forms(sForm) retrieves the required form from the forms collection, and (sForm)(sControl) the control from that retrieved forms control collection.
    Testimonial:
    pootle flump
    ur codings are working excelent.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •