Results 1 to 6 of 6
  1. #1
    Naveen Marapaka is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Dec 2012
    Posts
    33

    Dum Help with Date criteria

    Hi, kindly advise the solution here.



    I have Table : Stock_Utilization

    Fields : Out_Date, Dom_Regular_Pouch



    I have written below code for a button in Vba and the result I am getting Dsum value without taking the date criteria.

    what's wrong here.

    [CODE] [/MsgBox Nz(DSum("DOM_REGULAR_POUCH", "Stock_Utilization", (Month([OUT_DATE]) = Month(Now())) And (Year([OUT_DATE]) = Year(Now())))) CODE]



    regards

  2. #2
    Naveen Marapaka is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Dec 2012
    Posts
    33
    [CODE] MsgBox Nz(DSum("DOM_REGULAR_POUCH", "Stock_Utilization", (Month([OUT_DATE]) = Month(Now())) And (Year([OUT_DATE]) = Year(Now())))) [/ CODE]

  3. #3
    amrut is offline Expert
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2012
    Location
    India
    Posts
    616
    Can you mention what values do you want to sum instead of code in plain English ? Search DSum in top right corner of VBA window ("Type a question for help")

  4. #4
    Naveen Marapaka is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Dec 2012
    Posts
    33
    ok, I will try to explain taking sample data.

    Dom_regular_pouch has data as 50,100,54,8,6,68 and corresponding Out_date as 4/1/2014 , 4/25/2014, 5/1/2014, 5/1/2014, 5/2/2014, 5/3/2014

    so my code should give me result as 136 which is sum of values which are current month & year

    but I am getting value as 286 which is sum of all values without taking/checking date criteria which I mentioned in code.

    so I want Dsum code with correct code which will check date criteria of current month & year


    regards

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,602
    Criteria argument must be within quote marks, same as field and table arguments. The intrinsic Access functions should still evaluate.

    Try:

    MsgBox Nz(DSum("DOM_REGULAR_POUCH", "Stock_Utilization", "Format([Out_date],'yyyymm') = Format(Date(),'yyyymm')")

    If you want user specified criteria, enter date into textbox on form and concatenate reference to textbox.

    MsgBox Nz(DSum("DOM_REGULAR_POUCH", "Stock_Utilization", "Format([Out_date],'yyyymm') = '" & Format(Me.tbxDate,"yyyymm") & "'")
    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.

  6. #6
    Naveen Marapaka is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Dec 2012
    Posts
    33
    Quote Originally Posted by June7 View Post
    Criteria argument must be within quote marks, same as field and table arguments. The intrinsic Access functions should still evaluate.

    Try:

    MsgBox Nz(DSum("DOM_REGULAR_POUCH", "Stock_Utilization", "Format([Out_date],'yyyymm') = Format(Date(),'yyyymm')")

    If you want user specified criteria, enter date into textbox on form and concatenate reference to textbox.

    MsgBox Nz(DSum("DOM_REGULAR_POUCH", "Stock_Utilization", "Format([Out_date],'yyyymm') = '" & Format(Me.tbxDate,"yyyymm") & "'")


    thank you its working for me now

    Nz(DSum("DOM_REGULAR_POUCH", "STOCK_UTILIZATION_AND_OUTGOING", "Month([OUT_DATE]) = Month(Now()) And Year([OUT_DATE]) = year(Now())"))

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

Similar Threads

  1. Criteria to only id if not above date
    By Ruegen in forum Queries
    Replies: 1
    Last Post: 11-20-2013, 06:03 PM
  2. Date criteria using between and form date picker
    By killermonkey in forum Queries
    Replies: 3
    Last Post: 03-21-2013, 12:44 PM
  3. Replies: 3
    Last Post: 08-21-2012, 03:05 PM
  4. Criteria for date due
    By Desstro in forum Queries
    Replies: 4
    Last Post: 11-30-2010, 12:54 PM
  5. Date Criteria
    By tcollins02 in forum Queries
    Replies: 1
    Last Post: 09-09-2008, 08:27 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