?
Solved

DSum syntax issue

Posted on 2016-07-23
2
Medium Priority
?
46 Views
Last Modified: 2016-07-24
What is wrong with this:  (used on a form.  And AppliedToOpenOrdRecID and txtOpenOrderRecID are both numeric values)

Me.txtInventoryAppliedQty = Nz(DSum("[Quantity Out]", "tblInventoryDetail", "[AppliedToOpenOrdRecID] = Me!txtOpenOrderRecID, 0)
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
2 Comments
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 2000 total points
ID: 41725902
you lack the "&" symbol and a closing parenthesis ")"  before ",0)"

if "[AppliedToOpenOrdRecID]" is number

Me.txtInventoryAppliedQty = Nz(DSum("[Quantity Out]", "tblInventoryDetail", "[AppliedToOpenOrdRecID] =" & Me.txtOpenOrderRecID), 0)

if "[AppliedToOpenOrdRecID]" is Text

Me.txtInventoryAppliedQty = Nz(DSum("[Quantity Out]", "tblInventoryDetail", "[AppliedToOpenOrdRecID] ='" & Me.txtOpenOrderRecID & "'"), 0)


note: at this point for so many instances, you should have learned this syntax already.
0
 
LVL 58
ID: 41726558
Steve,

<<note: at this point for so many instances, you should have learned this syntax already.>>

 I'm sorry, but I have to say I would second that.  You've been asking this same question over and over for some time now.  

 We have pointed out what your doing wrong, and also have suggested many times now that you do it this way:

 Dim strWhere as string

strWhere = "[AppliedToOpenOrdRecID] = " & Me!txtOpenOrderRecID
Me.txtInventoryAppliedQty = Nz(DSum("[Quantity Out]", "tblInventoryDetail",strWhere), 0)

which your still not doing.

Doing this allows you to put a break point or a stop in place and inspect strWhere to see exactly what the statement sees when it executes if your having a problem.

If you do this, it will help a lot and in that you'll be able to see where your mistake is.  Please start doing this.

Also please read:

https://www.experts-exchange.com/articles/12/Dlookup-and-the-Domain-Functions.html

about half way down, that article deals with putting things inside a string (which is what the WHERE argument is), including other strings.

While we want to help in every way possible, most of us like to see some effort on your part in trying to learn what you have been having a problem with.

Thanks,
Jim.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

764 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