Solved

DSum syntax issue

Posted on 2014-01-17
8
286 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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

863 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

23 Experts available now in Live!

Get 1:1 Help Now