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:
Expand|Select|Wrap|Line Numbers
- '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)
Expand|Select|Wrap|Line Numbers
- '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