Solved

DSum syntax issue

Posted on 2016-07-23
2
43 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 500 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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
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 the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

696 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