Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2009
    Posts
    9

    Handling dates in queries

    Hi,

    I am trying to retrieve records from access mdb based on the date entered by the user. I am getting a type mismatch error for the select statement :

    strdate = CDate(Me.txtRequestDate)



    Set DBRecSet = dbs.OpenRecordset("select * from DBReq where RequestDate= # strdate #")

    I think the problem lies in the where clause. But I am unable to rectify this. Any pointers ?

    Thanks in advance,
    mrk68

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Try:
    Set DBRecSet = dbs.OpenRecordset("select * from DBReq where RequestDate= #" & Me.txtRequestDate & "#")

  3. #3
    rommelgenlight is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Mar 2009
    Posts
    77
    or since you have set your strdate, try removing "#" on your criteria.

  4. #4
    Join Date
    Mar 2009
    Posts
    9
    I got it working. I removed # in my criteria. Thanks.

  5. #5
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Excellent! Glad to hear you got it working.

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

Similar Threads

  1. Count Dates within Date Range
    By eckert1961 in forum Queries
    Replies: 2
    Last Post: 03-08-2009, 10:58 AM
  2. Replies: 0
    Last Post: 03-05-2009, 12:27 PM
  3. calculating due dates in access
    By trixxnixon in forum Forms
    Replies: 0
    Last Post: 09-28-2008, 12:35 PM
  4. Searching Dates
    By knightjp in forum Database Design
    Replies: 2
    Last Post: 08-16-2008, 11:39 PM
  5. Help with Searching Dates
    By rededdie in forum Access
    Replies: 1
    Last Post: 11-02-2007, 08:34 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