Is there a way to specify an object via name?

YevS

Registered User.
Local time
Today, 10:20
Joined
May 23, 2007
Messages
39
I'm trying to find a way to manipulate specifically named objects on the form via name.

Currently Ill run code like this to find every object:

Code:
Function (i as Integer)
 
Dim MyObject as Object
 
For Each MyObject in me.Controls
 
     If MyObject.Name = "Level" & i Then
 
          myObject.Value = "X"
     End If
Next

I want to try and avoid looping through all 60+ objects on my forms doesens of times for every user operation. Does anyone know of a way of specifying an object directly by using the name?
 
Given your example,

Me("Level" & i) = "X"
 
Ah I was trying with the dot... me.("level" & i)

Thanks :)
 
In general, where an object is or implies a collection, the Objname("contained-object-name") syntax is how you approach that. But beware of complex cases such as might occur when referencing a control on a sub-form from the parent form.
 

Users who are viewing this thread

Back
Top Bottom