Results 1 to 3 of 3

Thread: Link Please

  1. #1
    Join Date
    Feb 2004
    Location
    Irving, TX (Dallas, Fort Worth)
    Posts
    379

    Unanswered: Link Please

    All,

    Been searching the web and online tutorials for an alternative to:
    Code:
    For Each ctl In MyForm.Controls
         ....
    Next
    Where I can call the form control directly by name and either get or set its value. Kinda like:
    Code:
    MyForm.Controls.name = namestring
    MyForm.Controls.value = valuestring
    
    or
    
    namestring = MyForm.Controls.name
    valuestring = MyForm.Controls.value
    Without the For each loop.

    Not having any luck finding an example. Is my code correct?

    Anyone have a link to such a resource or example? Please supply link/url.

    Just don't want to go through all the interations of "for each => next" to get the right field. Want to get/assign directly.

    Thanks!

    DBS4M

  2. #2
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Quote Originally Posted by dbsupport4me
    Is my code correct?
    Didn't you try it?

    There's loads of ways - looping through would defo be wrong.

    Code:
    name = Me.ControlName.name
    name = Forms!MyForm!ControlName.name
    name = Forms("MyForm").Controls("ControlName").name
    Testimonial:
    pootle flump
    ur codings are working excelent.

  3. #3
    Join Date
    Feb 2004
    Location
    Irving, TX (Dallas, Fort Worth)
    Posts
    379

    Resolved

    All,

    All I needed was:
    Code:
    Dim MyForm as Form, ctl as Control
    
    Set ctl = MyForm.Controls(Fld_Nam)
    Which sets all the properties to ctl, name, value, etc., when "Fld_Nam" is the correct Form Field Name or the "Control Name".

    Thanks All!

    OMR

Posting Permissions

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