I need to be able to pass the name of an object into a variable and the use
the variable to alter that objects properties...
eg.
Variable1 = ActMod1.Name
Variable1.value = 15
variable1.ID = 0012
etc.
Does anyone know how to do this???
Printable View
I need to be able to pass the name of an object into a variable and the use
the variable to alter that objects properties...
eg.
Variable1 = ActMod1.Name
Variable1.value = 15
variable1.ID = 0012
etc.
Does anyone know how to do this???
I believe the best way to do what you want to do is to create a class for your object (assuming this is possible in your situation). You can then declare a variable as your new class, which essentially creates a new instance of your object. You can then use that variable name to assign and retreive properties, methods, whatever.
If you have never done this before, it's not that hard. You just add a class module to yuor project, create your class (you may have to look up how to do this - but it's easy enough), and then it will appear in the pop-up list as one of the available choices when you declare a variable.
Hope this helps!
JFDman
Here's an example without classes:This is only a quick example.Code:Private Sub Text1_LostFocus()
Call ValidateText(Text1)
End Sub
Private Sub ValidateText(cControl as Textbox) 'or as Control
If Len(cControl.Text) > 10 then
cControl.Text = Left(cControl.Text, 8)
End If
End Sub