Solved

DSum syntax issue

Posted on 2016-07-23
2
33 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
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 57
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

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.

Question has a verified solution.

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

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…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Familiarize people with the process of utilizing SQL Server views 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 Access…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

856 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