Hi guys
I'm trying to use the eval() function to run code that I have previously compiled via string concatenation.
Some of it works, for example, I can set the focus to a combo box called 'AssetIDLookup' , which is on the other form, with this code:
So far so good - the focus is successfully set and no errors. However, when I try to use the same method to set the text of that combo box, I keep getting the RunTime error described at the end of my post:
Here is the Run Time error (2482):
The application can't find the name 'Asset008' (the actual asset code from my variable) you entered in the expression.
Using msgbox or debug to check the string confirms that the statement is correct. And hardcoding that statement into the procedure also confirms that it works, ie. the combo box is set to eg. 'Asset008'.
Any help/hints would be greatly appreciated :-)
Thanks
Rob
I'm trying to use the eval() function to run code that I have previously compiled via string concatenation.
Some of it works, for example, I can set the focus to a combo box called 'AssetIDLookup' , which is on the other form, with this code:
Code:
'First building the string using variables: buildCommandString = "Forms!" & AppropriateFormName & "!AssetIDLookup.setfocus" 'Now use eval() and pass the string to have it converted to a VBA statement: Eval (buildCommandString)
Code:
'building the string buildCommandString = "Forms!" & AppropriateFormName & "!AssetIDLookup.Text = " & AssetID 'and useing eval() to treat it as a vba statement: Eval (buildCommandString)
The application can't find the name 'Asset008' (the actual asset code from my variable) you entered in the expression.
Using msgbox or debug to check the string confirms that the statement is correct. And hardcoding that statement into the procedure also confirms that it works, ie. the combo box is set to eg. 'Asset008'.
Any help/hints would be greatly appreciated :-)
Thanks
Rob
Comment