Solved

Very complicated syntax

Posted on 2014-11-28
8
106 Views
Last Modified: 2014-11-28
Can someone help me with this syntax?

=DSum("[QTY_ORDERED]","tblInventory","[PART_NO] = '" & [Forms]![frmParts]![txtPART_NO] & "' AND [TRNX_TYPE] in ('I','O')") + (DSum("QTY_ORDERED]","tblInventory","[PART_NO] = '" & [Forms]![frmParts]![txtPART_NO] & "' AND IsNull([TRNX_TYPE]) - DSum("QTY_ORDERED]","tblInventory","[PART_NO] = '" & [Forms]![frmParts]![txtPART_NO] & "' AND IsNotNull([DATE_RECD]))

I probably have a lot wrong with it.
0
Comment
Question by:SteveL13
  • 4
  • 4
8 Comments
 
LVL 49

Expert Comment

by:Gustav Brock
Comment Utility
Try this:

=DSum("[QTY_ORDERED]","tblInventory",
"[PART_NO] = '" & [Forms]![frmParts]![txtPART_NO] & "' AND [TRNX_TYPE] in ('I','O')") +
(DSum("QTY_ORDERED]","tblInventory",
"[PART_NO] = '" & [Forms]![frmParts]![txtPART_NO] & "' AND [TRNX_TYPE] Is Null") -
DSum("QTY_ORDERED]","tblInventory",
"[PART_NO] = '" & [Forms]![frmParts]![txtPART_NO] & "' AND [DATE_RECD] Is Not Null")

/gustav
0
 

Author Comment

by:SteveL13
Comment Utility
Am getting a #Error in the field on the form.

But when I copy/pasted your suggestion into the control source it didn't complain except that it wanted a ) at the end.
0
 
LVL 49

Expert Comment

by:Gustav Brock
Comment Utility
Oh, sorry, but it's the other way round (line 3):

=DSum("[QTY_ORDERED]","tblInventory",
 "[PART_NO] = '" & [Forms]![frmParts]![txtPART_NO] & "' AND [TRNX_TYPE] in ('I','O')") +
DSum("QTY_ORDERED]","tblInventory",
 "[PART_NO] = '" & [Forms]![frmParts]![txtPART_NO] & "' AND [TRNX_TYPE] Is Null") -
DSum("QTY_ORDERED]","tblInventory",
 "[PART_NO] = '" & [Forms]![frmParts]![txtPART_NO] & "' AND [DATE_RECD] Is Not Null")

/gustav
0
 

Author Comment

by:SteveL13
Comment Utility
Hmmm,

I tried picking this apart in sections.  When I cop/pasted the first part it gave me a result:

=DSum("[QTY_ORDERED]","tblInventory",
 "[PART_NO] = '" & [Forms]![frmParts]![txtPART_NO] & "' AND [TRNX_TYPE] in ('I','O')")

But when I tried the 2nd part by itself:

=DSum("QTY_ORDERED]","tblInventory",
  "[PART_NO] = '" & [Forms]![frmParts]![txtPART_NO] & "' AND [TRNX_TYPE] Is Null")

I get #Error in the field.
0
Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

 
LVL 49

Accepted Solution

by:
Gustav Brock earned 500 total points
Comment Utility
You should correct the typo:

=DSum("[QTY_ORDERED]"

also for the third part.

/gustav
0
 

Author Closing Comment

by:SteveL13
Comment Utility
Perfect!
0
 
LVL 49

Expert Comment

by:Gustav Brock
Comment Utility
Also, you may need to prevent Nulls:

=Nz(DSum("[QTY_ORDERED]","tblInventory",
  "[PART_NO] = '" & [Forms]![frmParts]![txtPART_NO] & "' AND [TRNX_TYPE] in ('I','O')"), 0)

for all three parts.

/gustav
0
 

Author Comment

by:SteveL13
Comment Utility
Ok.  Will do.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now