Solved

Very complicated syntax

Posted on 2014-11-28
8
112 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
8 Comments
 
LVL 50

Expert Comment

by:Gustav Brock
ID: 40470579
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
ID: 40470591
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 50

Expert Comment

by:Gustav Brock
ID: 40470609
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:SteveL13
ID: 40470633
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
 
LVL 50

Accepted Solution

by:
Gustav Brock earned 500 total points
ID: 40470642
You should correct the typo:

=DSum("[QTY_ORDERED]"

also for the third part.

/gustav
0
 

Author Closing Comment

by:SteveL13
ID: 40470693
Perfect!
0
 
LVL 50

Expert Comment

by:Gustav Brock
ID: 40470695
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
ID: 40470748
Ok.  Will do.
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

740 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