Solved

Very complicated syntax

Posted on 2014-11-28
8
110 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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 

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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Familiarize people with the process of utilizing SQL Server stored procedures 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 Micr…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

792 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