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

    Error in code vba


    Hello guys
    What is wrong with this code ?
    intContractCount = Nz(DCount("PaymentID", "Payments", "PaymentDate= Between DateAdd('d',-60,Date()) And DateAdd('m',-2,Date())"), 0)
    Thank you very much in advance

  2. #2
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Between or =, not both.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    azhar2006's Avatar
    azhar2006 is offline Expert
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2012
    Posts
    528
    Click image for larger version. 

Name:	55e.JPG 
Views:	8 
Size:	64.6 KB 
ID:	31615Show me this message

  4. #4
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    The comma shouldn't be there. Perhaps I should have said:

    "Between" or "=" not both.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    azhar2006's Avatar
    azhar2006 is offline Expert
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2012
    Posts
    528
    Thank you my friend pbaldy

  6. #6
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    No problem, sorry for being unclear.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. SQL code error
    By Lou_Reed in forum Access
    Replies: 49
    Last Post: 06-21-2017, 11:57 AM
  2. code error??
    By Jen0dorf in forum Access
    Replies: 1
    Last Post: 11-14-2015, 12:16 PM
  3. Error in code
    By cbende2 in forum Programming
    Replies: 5
    Last Post: 06-04-2015, 10:39 AM
  4. Error in VBA Code
    By guillermoftw in forum Access
    Replies: 3
    Last Post: 02-10-2015, 12:12 PM
  5. VBA Code Returning Error Run Time Error 3061
    By tgwacker in forum Access
    Replies: 2
    Last Post: 11-24-2013, 11:00 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