Help with function in string

dmr

Registered User.
Local time
Today, 03:01
Joined
Dec 15, 2009
Messages
34
I have a variable, emailBody, which is set to a string stored in a database. The email body is set to a string via a dlookup function.
emailBody = DLookup("emailBody", "listAdditions", "Id = " & itemType)
The string that email body is set to includes an IIf function (which includes a dlookup function). When
?emailBody is entered in the immediate window during runtime, it shows that emailBody is set to the following string:
The new commodity is" & Iif(dlookup("IsVague", "CommodityType", "Description= " & newItem)="1", "vague.", "not vague.")
However, I want the dlookup and IIf functions to be evaluated and their results stored in the string. How do I properly format the emailBody string ("the new commodity...") in my database so that the functions will be evaluated and the results stored in the emailBody variable?
 
The table entry needs to be changed to NOT include the DLookup there, and you would incorporate it in the code. You can put a place holder like

<IIF>

in the text and then use REPLACE to replace the <IIF> part with the DLookup results.
 
I want the entire body, including the dlookup, to be saved as a string in the table. (I want to do it this way so that every email can have an entirely different body and I can use one email function for all of them).
Is there any way to keep the dlookup in the table?
 
I want the entire body, including the dlookup, to be saved as a string in the table. (I want to do it this way so that every email can have an entirely different body and I can use one email function for all of them).
Is there any way to keep the dlookup in the table?

Keep the Dlookup in a separate field and then in the code you would use

the EVAL function to let it evaluate the function, but amazingly enough you'll still need a separate DLookup to lookup the Dlookup so it can be evaluated and then inserted using Replace into the other string.
 

Users who are viewing this thread

Back
Top Bottom