How to get Object property using EVAL()?
Can you figure out how to do this?
I want to get the value of an object property. The trick is that the name of the property to retrieve is stored in a table.
Here's how I've set it up:
I have a class module "objPerson" which has a property "FirstName".
I can type: objPerson.FirstName = "John Smith"
and then the statement: strFirstName = objPerson.FirstName
will correctly result in strFirstName = "John Smith"
So far, so good, right?
Next, in "MyTable" I have a field "MyField" which contains the text string "objPerson.FirstName"
I want to get the value of the item specified by the string in MyField. In other words, I want the program to determine the value of whatever object property that I have stored in MyField. In this case, I have opened the object objPerson and I want the program to give me the value of "objPerson.FirstName".
I've tried using Eval(), but so far it doesn't work:
strFirstName = Eval(rst.Fields("MyField"))
The result is: "Error 2482: Microsoft Access can't find the name 'objTenant' you entered in the expression."
|