Results 1 to 3 of 3
  1. #1
    desk4tbc is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2011
    Posts
    29

    DSum Syntax Help

    Help! I'm completely at a loss at the syntax for dsum! I have the following:



    intSum = DSum("[Amount Paid]","FileList","[Accession Number] = '" & Me![Accession Number] & "'" And Book = Me![Book]")

    I'm trying to sum the "Amount Paid" column in the "FileList" table with the conditions that the accession number and the book in the "FileList" table are the same as the values in the form with controls with the same name.

    Amount Paid, Accession Number are both stored as numbers while Book is stored as a string. I'm getting an invalid syntax error. Help!

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Need to concatenate the Me![Book] and assuming [Accession Number] and [Book] fields are text datatype:

    intSum = DSum("[Amount Paid]","FileList","[Accession Number] = '" & Me![Accession Number] & "' And Book = '" & Me![Book] & "'")
    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
    desk4tbc is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2011
    Posts
    29
    Thanks! That did the trick after messing with the ' locations.

    Code:
    intSum = DSum("[Amount Paid]", "FileList", "[Accession Number] = " & Me![Accession Number] & " And [Book] = '" & Me![Book] & "'")

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

Similar Threads

  1. Replies: 13
    Last Post: 12-05-2011, 05:10 AM
  2. Help with Sum and DSum
    By objNoob in forum Reports
    Replies: 5
    Last Post: 12-05-2011, 01:55 AM
  3. Incomplete Syntax Clause (syntax error)
    By ajetrumpet in forum Programming
    Replies: 4
    Last Post: 09-11-2010, 10:47 AM
  4. How do I use the DSum
    By Ironclaw in forum Access
    Replies: 1
    Last Post: 08-25-2010, 07:35 AM
  5. Help with dsum
    By bjsbrown in forum Reports
    Replies: 6
    Last Post: 02-06-2010, 09:33 AM

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