Solved

Very complicated syntax

Posted on 2014-11-28
8
109 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
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 49

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
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 

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 49

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 49

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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
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…

803 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