Results 1 to 3 of 3

Thread: Object name in string

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 1999
    Location
    Galway, Ireland
    Posts
    316

    Post

    I have a string with my text box name in it ie
    dim mystring as string
    mystring = "text1"
    how to I change a proprrty using only the string

    ie
    mystring.text = "hello"
    help please
    john_m_murphy@hotmail.com


    ------------------
    Slan

  2. #2
    Junior Member
    Join Date
    Nov 1999
    Location
    Forsyth, GA, USA
    Posts
    26

    Post

    It might be done by referencing the Fields collection of the form. If you iterate through the Fields collection to find your target field by name you should have access to all of the properties of the object.

  3. #3
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999
    Location
    UK
    Posts
    1,845

    Post

    I wanted to do something simular some time ago because i wanted to map database field names to controls

    This works, but does it do waht you want

    Dim mystring As Object
    Dim MyObject As Control

    For Each MyObject In Form1.Controls
    If MyObject.Name = "Text1" Then
    Set mystring = MyObject
    Exit For
    End If
    Next

    mystring.Text = "hello"

Posting Permissions

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



Click Here to Expand Forum to Full Width