Results 1 to 3 of 3
  1. #1
    newbieX is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Jul 2013
    Posts
    111

    Variable concatenation woes on DSum

    I know I have quotes or something like that in the wrong order but where? I've spent hours on this one line.

    Code:
    CustID = "ABD-33-JJPP"
    
    APPLE_TOTAL = Nz(DSum("[FRUITtotal]", "tbl_FRUIT", "[FRUIT] = 'Apple' AND [BRAND] = 'Pink Lady' AND [Customer] = '" & CustID & "'))"
    I get the following error:

    Compile error:
    Expected: list separator or )

    Why? I hate concatenating variables. I can never get it right. Arrrrgggghhhhhh



    I want to total all the pink lady fruit that the variable CustID ordered.

  2. #2
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    You're going to slap yourself.........You have the last double quote in the wrong place. Should be inside the 2 closing parentheses.

    Try:
    Code:
    Nz(DSum("[FRUITtotal]", "tbl_FRUIT", "[FRUIT] = 'Apple' AND [BRAND] = 'Pink Lady' AND [Customer] = '" & CustID & "'"))
    Expanded, it looks like

    Nz( DSum("[FRUITtotal]", "tbl_FRUIT", "[FRUIT] = 'Apple' AND [BRAND] = 'Pink Lady' AND [Customer] = ' " & CustID & " ' " ) )

  3. #3
    newbieX is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Jul 2013
    Posts
    111
    Yes. And thanks for coloring coding response so I could wrap my head around it better.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Me.Filter with variable woes
    By chris.williams in forum Programming
    Replies: 3
    Last Post: 08-21-2012, 01:03 PM
  2. Combo Box Woes
    By tbassngal in forum Forms
    Replies: 2
    Last Post: 09-01-2011, 08:54 AM
  3. DSum criteria using a variable that has been defined
    By beanhead0321 in forum Programming
    Replies: 5
    Last Post: 07-24-2011, 09:57 PM
  4. error message woes
    By ggs in forum Forms
    Replies: 4
    Last Post: 05-29-2011, 04:03 AM
  5. Combo box woes...
    By jonbonazza in forum Forms
    Replies: 3
    Last Post: 06-21-2010, 11:34 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums