Link to home
Start Free TrialLog in
Avatar of SteveL13
SteveL13Flag for United States of America

asked on

DSum not working correctly

I am using DSum as a default value on a form but am not getting the correct result.  Probably because I have " and ' marks wrong.  Can someone help?  Here my code:

=DSum("Qty","tblProdInventory","'Style = #10 Product' & 'CompanyName = frmProjectDetail!txtCompany'")

--Steve
Avatar of Scott McDaniel (EE MVE )
Scott McDaniel (EE MVE )
Flag of United States of America image

=DSum("Qty","tblProdInventory","Style = '#10 Product' AND CompanyName ='" &  frmProjectDetail!txtCompany & "'")
Sorry, posted too quickly:

Also, understand that a Default value ONLY impacts New records. It will have absolutely no impact on Existing records.

And, in your case, if there is no value in txtCompany, or if txtCompany is on the same Form where you're running this, then you will almost certainly run into issues with it.
Avatar of SteveL13

ASKER

I pasted this in the default value and am getting a #Name? result.   ??
Try this one

=DSum("[Qty]","tblProdInventory","[Style] = '#10 Product' And  [CompanyName] =' " & Forms!frmProjectDetail!txtCompany & "'")

Sincerely,
Ed
Tried that one and now I get no result in the field.
No leading space:

=DSum("Qty","tblProdInventory","Style = '#10 Product' And CompanyName = '" & frmProjectDetail!txtCompany & "'")

/gustav
i = DSum("Qty", "tblProdInventory", "Style = '#10 Product' And CompanyName = 'frmProjectDetail!txtCompany'")
cactus_data:

my bad. i didnt refresh before i saw your comment
ASKER CERTIFIED SOLUTION
Avatar of Scott McDaniel (EE MVE )
Scott McDaniel (EE MVE )
Flag of United States of America 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