+ Reply to Thread
Results 1 to 4 of 4

Function to return object reference given object name

  1. #1
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,705

    Function to return object reference given object name

    Is there a function to return an object reference, given the object name as a string? For example, its spec would be:

    Please Login or Register  to view this content.
    I have several labels on a form that I would like to be able to iterate through in a loop. They are named, for example, Label1, Label2, etc. If I could refer to the objects by name, then I could do something like:

    Please Login or Register  to view this content.
    Currently my workaround is to have an array of Object, and initialize it by setting each element to one of the labels, then working with the array. Would be nice to address the labels directly.
    Last edited by 6StringJazzer; 04-28-2010 at 09:09 PM.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  2. #2
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Function to return object reference given object name

    Perhaps something like this:

    Please Login or Register  to view this content.
    Is your code running too slowly?
    Does your workbook or database have a bunch of duplicate pieces of data?
    Have a look at this article to learn the best ways to set up your projects.
    It will save both time and effort in the long run!


    Dave

  3. #3
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Function to return object reference given object name

    You can use Controls:
    Please Login or Register  to view this content.
    Note: Labels don't have a Value property.
    Remember what the dormouse said
    Feed your head

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,705

    Re: Function to return object reference given object name

    Quote Originally Posted by davegugg View Post
    Perhaps something like this:

    Please Login or Register  to view this content.
    I think I can adapt this to something like this, which I haven't tested:
    Please Login or Register  to view this content.
    It's not fast but may be good enough for my purposes.

    Quote Originally Posted by romperstomper View Post
    Note: Labels don't have a Value property.
    Oh, good point. Should be Caption.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1