Link to home
Start Free TrialLog in
Avatar of pdvsa
pdvsaFlag for United States of America

asked on

Dlookup

Hello, I am trying to substract 2 separate values in the following but I get a #error.  I imagine its a paren but not sure where.  thank you in advance.  

=DLookUp("Amount_ Aggregate","tblDraws","ID=" & [DrawIDrpmt])-DLookUp("Amount","tblDraws_Details1","DrawIDrpmt=" & [ DrawIDrpmt])
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

you may break down your function into 2 parts...

first using your first part of function and see what was being returned?
=DLookUp("Amount_ Aggregate","tblDraws","ID=" & [DrawIDrpmt])

Open in new window

similarly, do the same for the 2nd function:
=DLookUp("Amount","tblDraws_Details1","DrawIDrpmt=" & [ DrawIDrpmt]) 

Open in new window

this will give you clue which part is getting an error and let you handle that error more efficiently.
ASKER CERTIFIED SOLUTION
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I imagine its a paren
Or missing Operator?

The first argument in DLookup is an expression where vba checks for missing operators.

DLookup ("x + 2", ...: Expression to look for value of field x + 2.

In what Rayan assumed, your code assumes, because of a space in the name,  a missing operator between assumed fields: "Amount_" and "Aggregate".
Avatar of pdvsa

ASKER

That was it.  Thank you