Question evaluate a string to make an expression

mlupini

New member
Local time
Yesterday, 16:08
Joined
Jan 11, 2013
Messages
3
This returns the correct value
Debug.Print [myTable]![myField]
Why does this result in an error?
Debug.Print Eval("[myTable]![myField]")
 
Maybe you should put it this way:

Debug.Print Eval(" & [myTable]![myField] & ")
 
Where are you attempting to use it and how?
 
I want to enter calculated field formulas in a table then use the result in a query.
I've done a lot of searches and it appears you cannot do this.
 
I want to enter calculated field formulas in a table then use the result in a query.
I've done a lot of searches and it appears you cannot do this.
You can if you write a custom function to do the job though. If you give a couple of examples of what you want to calculate (your formulas you are storing) we can make some suggestions on how to write a function to deal with them.
 
SELECT Slots.RackName, Slots.SlotID, Slots.PartID, _
Parts.BaseI, _
IIf([Slots].[PartID]=25, _
[RackName] & ':I', _
[RackName] & ':' & [SlotID] & ':I') _
AS BaseITag
FROM Parts _
INNER JOIN Slots _
ON Parts.PartID = Slots.PartID;

For each PartID I have a field that stores the calc string.
In this case (this is the simplest of many).
[Parts].[BaseI] = "[RackName] & ':I'"
or [Parts].[BaseI] = "[RackName] & ':' & [SlotID] & ':I'"

I want to replace the IIf statement with
Eval([Parts].[BaseI]) AS BaseITag

Hopefully this is clear enough.
 

Users who are viewing this thread

Back
Top Bottom