So I’ve determined that DLookup may be the key to accomplishing what I’ve set out to do. Some preliminary orientation before I jump right in to code: Additives is a table containing the fields AdditiveName and ID, the latter of which is the table’s primary key. All Samples is a table that contains the fields Additive1ID, Additive2ID, Additive3ID and Weight%1, Weight%2, and Weight%3, where the three AdditiveIDs are foreign keys that link to the Additive table. I have a query called combine additives with a field containing the expression I’m trying to build.
Starting with my original expression:
Code:
[Weight%1]*100 & ”% “ & [Additive1ID] & " " & [Weight%2]*100 & ”% “ & [Additive2ID] & " " & [Weight%3]*100 & ”% “ & [Additive3ID]
I’ve replaced any instance of AdditiveXID (where X is 1, 2, or 3) with:
Code:
DLookUp("[AdditiveName]","Additives","[ID] = Tables![All Samples]![AdditiveXID]")
When I run the query I get an error message that says,
The expression you entered as a query parameter produced this error: ‘Microsoft Office Access can't find the name ‘Tables!All Samples!Additive1ID’ you entered in the expression’
So what am I doing wrong?
PS Since the AdditiveXID fields in my All Samples table are 2 column comboboxes (the first column is ID (it’s hidden) and the second is AdditiveName, both fields from my additive table. I also tried replacing AdditiveXID with AdditiveXID.Column(1) but that resulted in an error:
Undefined function ‘Additive1ID.Column’ in expression.
What was the problem with what I did there?