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
Solved

DSum syntax issue

Posted on 2014-01-17
8
294 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
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 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
 
LVL 40

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

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

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…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

829 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