none
[Access 2003+SQL-VBA] Dcount with 2 conditions (dates and criteria) RRS feed

  • Question

  • Hi,

    I want the code to show the number of good products between 2 custom dates, but this code is not working:

    txtResult = DCount("[ClientName]", "Table1", "[Product] = 'Good'" And "dateRef Between #" & [txtStartDate] & "# And #" & [txtEndDate] & "#")
    
    
    
    

    How to fix it, please?

    Thanks



    • Edited by iboumiza Tuesday, August 23, 2011 5:50 PM refine
    Tuesday, August 23, 2011 5:49 PM

Answers

  • iboumiza wrote:
    > I want the code to show the number of good products between 2 custom
    > dates, but this code is not working:
    >
    > txtResult = DCount("[ClientName]", "Table1", "[Product] = Good" And
    > "dateRef Between #" & [txtStartDate] & "# And #" & [txtEndDate] &
    > "#")
     
    txtResult = DCount("ClientName", "Table1", "Product = 'Good' And dateRef Between " & CLng(Me!txtStartDate) & " And " & CLng(Me!txtEndDate))
     
     
    --
    cu
    Karl
    *********
    Access-FAQ (German/Italian): http://www.donkarl.com
     
     
     


    • Marked as answer by iboumiza Tuesday, August 23, 2011 6:49 PM
    Tuesday, August 23, 2011 5:56 PM