Results 1 to 4 of 4
  1. #1
    azhar2006's Avatar
    azhar2006 is offline Expert
    Windows 7 32bit Access 2007
    Join Date
    Mar 2012
    Posts
    528

    What is wrong with this expression


    Hello all
    What is wrong with this expression
    And put it in a text box on a report disorganized but show me this message
    = DSum ("[sales]", "[Sales_Demo]", "[Product Name] = [orange]")

    Click image for larger version. 

Name:	ee.PNG 
Views:	10 
Size:	31.7 KB 
ID:	17554

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Don't use [] for literal text, use apostrophe.

    = DSum("[sales]", "[Sales_Demo]", "[Product Name] = 'orange'")
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    NTC is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2009
    Posts
    2,392
    J7 advised against the [] but then left them in - - I think that was a typo

    first sanity check this: = DSum("sales", "Sales_Demo")

    once that works, then add in your criteria - what is displayed looks correct off the cuff: = DSum("sales", "Sales_Demo", "[Product Name] = 'orange'")

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Then why did you leave [] around [Product Name] and not Sales or Sales_Demo?

    No typo. The [] are used around field and object names. In fact, they are required if names have spaces or special characters/punctuation (underscore is exception). There is a space in [Product Name]. Although not required for Sales and Sales_Demo, doesn't hurt.

    I said don't use the [] with literal text.

    The word orange is literal text, not a name - it is a filter parameter.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Replies: 3
    Last Post: 02-12-2014, 03:36 PM
  2. Replies: 7
    Last Post: 08-13-2013, 11:03 PM
  3. What's wrong with this expression in a query?
    By djclntn in forum Queries
    Replies: 18
    Last Post: 11-17-2011, 06:12 PM
  4. Expression gives wrong results
    By newtoAccess in forum Queries
    Replies: 22
    Last Post: 12-03-2010, 12:21 AM
  5. What's wrong with this expression
    By tallroger in forum Access
    Replies: 1
    Last Post: 05-05-2009, 04:00 PM

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