Results 1 to 3 of 3
  1. #1
    chrisdd is offline Novice
    Windows 10 Office 365
    Join Date
    Mar 2020
    Posts
    13

    DSUM with multiple criteria including Null

    Hi,

    Can someone please look at the DSUM expression below and tell me where I'm going wrong

    I need to search for stock in a database based on the day it was added - this works

    Me.Result = DSum("[SubTotal]", "Stock", "[DateAdded]<= # " & Format$(Me.DateInput, "mm/dd/yyyy") & "#")

    However whenever I put in criteria to remove stock that has been sold and will therefore have an OrderID asscoiated with it

    Me.Result = DSum("[SubTotal]", "Stock", "[DateAdded]<= # " & Format$(Me.DateInput, "mm/dd/yyyy") & "#" and isNull([OrderID]))



    I get the access can't find the field error even though the field is in the database.

    Thanks

  2. #2
    Join Date
    Apr 2017
    Posts
    1,792
    What about Nz([OrderID],0) = 0

  3. #3
    CarlettoFed is offline Competent Performer
    Windows 7 64bit Access 2013 32bit
    Join Date
    Dec 2019
    Posts
    274
    The original code
    Code:
    Me.Result = DSum("[SubTotal]", "Stock", "[DateAdded]<= # " &  Format$(Me.DateInput, "mm/dd/yyyy") & "#" and isNull([OrderID]))
    must be changed to
    Code:
    Me.Result = DSum("[SubTotal]", "Stock", "[DateAdded]<= # " &  Format$(Me.DateInput, "mm/dd/yyyy") & "# And IsNull([OrderID])")
    or
    Code:
    Me.Result = DSum("[SubTotal]", "Stock", "[DateAdded]<= " & CLng(Me.DateInput) & " And IsNull([OrderID])")
    if the OrderID field is found in the Stock table.

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

Similar Threads

  1. Replies: 2
    Last Post: 05-05-2017, 03:24 PM
  2. Replies: 3
    Last Post: 08-25-2016, 09:12 AM
  3. Query Criteria not including null values
    By shaun_za in forum Queries
    Replies: 1
    Last Post: 09-09-2015, 07:01 AM
  4. Replies: 5
    Last Post: 11-30-2014, 08:12 PM
  5. Replies: 11
    Last Post: 04-30-2012, 07:22 PM

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