Can you figure out how to do this in Access2002/VBA?
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" .
This works:
and it will correctly set
strFirstName = "John Smith"
So far, so good, right?
Next, in "MyTable" I have a field "MyField" which contains the text string "objPerson.Firs tName"
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.Firs tName".
I've tried using Eval(), but so far it doesn't work:
The result is: "Error 2482: Microsoft Access can't find the name 'objTenant' you entered in the expression."
MY OBJECTIVE
My objective is to do string replacement where the REPLACEMENT text is set in a table, like 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" .
This works:
Code:
objPerson.FirstName = "John Smith" strFirstName = objPerson.FirstName
strFirstName = "John Smith"
So far, so good, right?
Next, in "MyTable" I have a field "MyField" which contains the text string "objPerson.Firs tName"
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.Firs tName".
I've tried using Eval(), but so far it doesn't work:
Code:
strFirstName = Eval(rst.Fields("MyField"))
MY OBJECTIVE
My objective is to do string replacement where the REPLACEMENT text is set in a table, like this:
Code:
In "MyTable": Field:KEY Field:REPLACE_WITH ------------------------- ------------------------------------- Tenant.FirstName objTenant.FirstName Owner.FirstName objOwner.FirstName Balance objInvoice.BalanceAmount (etc...) strMsg = "Hello [Tenant.FirstName]. Your invoice balance is [Invoice.Balance]" strMsg = MySpecializedReplacementFunction(strMsg) strMsg: "Hello John. Your invoice balance is $10"
Comment