Solved

DSum syntax issue

Posted on 2014-01-17
8
282 Views
Last Modified: 2014-01-18
What is wrong with:

Me.txtShippedQty = DSum("[ShippedQty]", "tblReady", "[ReadyID] = " & Forms!frmPlanted.subfrmReady!txtReadyID) And ("[Bay] = " & Forms!frmPlanted.subfrmReady!txtBay)

--Steve
0
Comment
Question by:SteveL13
  • 2
  • 2
  • 2
  • +2
8 Comments
 
LVL 15

Expert Comment

by:Ess Kay
ID: 39788490
what are you trying to do
0
 

Author Comment

by:SteveL13
ID: 39788498
Sum qty where

Me.txtShippedQty = DSum("[ShippedQty]", "tblReady", "[ReadyID] = " & Forms!frmPlanted.subfrmReady!txtReadyID) And ("[Bay] = " & Forms!frmPlanted.subfrmReady!txtBay)

and

("[Bay] = " & Forms!frmPlanted.subfrmReady!txtBay)

the subform subfrmReady is a subform in frmPlanted
0
 
LVL 15

Expert Comment

by:Ess Kay
ID: 39788501
Me.txtShippedQty = DSum

(

     "[ShippedQty]",
       "tblReady",
        "[ReadyID] = " & Forms!frmPlanted.subfrmReady!txtReadyID

)

And ("[Bay] = " & Forms!frmPlanted.subfrmReady!txtBay)




i dont get it, i think you want this instead

Me.txtShippedQty = DSum

(

"[ShippedQty]", "tblReady", "[ReadyID] = " & Forms!frmPlanted.subfrmReady!txtReadyID & "[Bay] = " & Forms!frmPlanted.subfrmReady!txtBay

)

0
 
LVL 84
ID: 39788528
If [Bay] is a Text field:

Me.txtShippedQty = DSum("ShippedQty", "tblReady", "[ReadyID] = " & Forms!frmPlanted.subfrmReady!txtReadyID) & " AND [Bay] = '" & Forms!frmPlanted.subfrmReady!txtBay) & "'")

Open in new window


Note I changed some of the syntax as well - I added an ampersand and double quote just before the AND keyword. I also removed the square brackets from ShippedQty, since it's already enclosed in double quotes.
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 39

Expert Comment

by:als315
ID: 39788532
Me.txtShippedQty = DSum("[ShippedQty]", "tblReady", "[ReadyID] = " & Forms!frmPlanted.subfrmReady!txtReadyID & " And [Bay] = " & Forms!frmPlanted.subfrmReady!txtBay & ")"

Open in new window

if [ReadyID] and [Bay] are numeric
or
Me.txtShippedQty = DSum("[ShippedQty]", "tblReady", "[ReadyID] = " & Forms!frmPlanted.subfrmReady!txtReadyID & " And [Bay] = " & chr(34) & Forms!frmPlanted.subfrmReady!txtBay & chr(34) & ")"

Open in new window

if [ReadyID] is numeric and [Bay] is text
0
 

Author Comment

by:SteveL13
ID: 39788565
Both ShippedQty and Bay are numeric.  

This does not work...

Me.txtShippedQty = DSum("[ShippedQty]", "tblReady", "[ReadyID] = " & Forms!frmPlanted.subfrmReady!txtReadyID & " And [Bay] = " & chr(34) & Forms!frmPlanted.subfrmReady!txtBay & chr(34) & ")"

"Expected list separator or )"  error
0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 39788567
going back to my recommendation from yesterday and numerous times in the past.  Split your criteria out of the domain function, so that you can test it.

strCriteria = "[ReadyID] = " & Forms!frmPlanted.subfrmReady!txtReadyID) _
                   & " And [Bay] = " & Forms!frmPlanted.subfrmReady!txtBay
debug.print strCriteria
Me.txtShippedQty = DSum("[ShippedQty]", "tblReady", strCriteria)

That should work, if [bay] is numeric.  Use the following if it is text:

strCriteria = "[ReadyID] = " & Forms!frmPlanted.subfrmReady!txtReadyID) _
                   & " And [Bay] = '" & Forms!frmPlanted.subfrmReady!txtBay & "'"
0
 
LVL 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 500 total points
ID: 39789969
Are these values you're trying to get to on a Subform? If so:

Me.txtShippedQty = DSum("[ShippedQty]", "tblReady", "[ReadyID] = " & Forms!frmPlanted.subfrmReady.Form!txtReadyID & " And [Bay] = " & chr(34) & Forms!frmPlanted.subfrmReady.Form!txtBay & chr(34) & ")"

You must add the Form qualifier after the subfrmReady - and also be sure that "subfrmReady" is the name of the Subform CONTROL on frmPlanted. Access will name them different things, depending on how you insert the control, so be sure of that.
"Expected list separator or )"  error
You don't need the & and "" around the last parentheses:

Me.txtShippedQty = DSum("[ShippedQty]", "tblReady", "[ReadyID] = " & Forms!frmPlanted.subfrmReady.Form!txtReadyID & " And [Bay] = " & chr(34) & Forms!frmPlanted.subfrmReady.Form!txtBay & chr(34))

That last parentheses is the mate to the first open parentheses immediately after DSum ...
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.

Join & Write a Comment

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
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 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…
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…

708 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now