Results 1 to 6 of 6
  1. #1
    Praveenevg is offline Novice
    Windows 8 Access 2007
    Join Date
    Aug 2014
    Posts
    18

    FindFirst not working when using DATE field in criteria


    Hello,

    I have spent more than 5 hours so far to make the FindFirst command work for a date value, and still made no progress.

    Please help me on following:

    For some reason FindFirst is not working whenever my search criteria constains a date field and date value. Visually, I can see a record in table with the same date I am searching for. Is there anything to consider while searching using a date field?

  2. #2
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Where are you using the FindFirst - in VBA?

    When searching for dates, the value must be enclosed in '#' marks, and must be in mm/dd/yyyy format. I know that's not the format used in most places, but that's what Access needs. It's not that difficult, though. A FindFirst on a recordset would look something like this:

    rst.FindFirst "Datefield = #" & format(searchdate,"mm-dd-yyyy") & "#"

    where Datefield is the recordset field to be searched, and searchdate is the date value you are looking for.

    HTH

    John
    Last edited by John_G; 08-19-2014 at 06:50 AM. Reason: fix typo

  3. #3
    Praveenevg is offline Novice
    Windows 8 Access 2007
    Join Date
    Aug 2014
    Posts
    18
    Thanks a Ton. it worked. I spent a day so far troubleshooting this and finally your solution made it to work.

  4. #4
    recyan's Avatar
    recyan is offline Expert
    Windows 2K Access 2000
    Join Date
    Dec 2011
    Posts
    662
    Do not know about FindFirst in VBA & may not be relevant to this case, all the same,
    while working with "First" in Queries with Grouping, found that "Min" & "First" could throw up different results at times.

    Thanks

  5. #5
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    recyan -

    "Min" & "First" could very easily give you different values; it would depend on the sort order used in the query, or on whatever order MS Access chooses to use. "Min" will always give you the same value, but changing the sort order could change the value you get using "First"

    John

  6. #6
    recyan's Avatar
    recyan is offline Expert
    Windows 2K Access 2000
    Join Date
    Dec 2011
    Posts
    662
    Was wondering whether "FindFirst" in VBA & "First" in Grouping query are the same functionally.

    Thanks

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

Similar Threads

  1. Replies: 7
    Last Post: 09-28-2023, 08:41 AM
  2. FindFirst Not Working with Decimal Data Type
    By JonMulder in forum Programming
    Replies: 5
    Last Post: 01-22-2013, 01:26 PM
  3. Recordset FindFirst Not Working
    By ShoresJohn in forum Programming
    Replies: 5
    Last Post: 03-01-2012, 06:59 PM
  4. FINDFIRST Multiple criteria
    By trigirl67 in forum Forms
    Replies: 1
    Last Post: 01-31-2012, 02:02 PM
  5. using FindFirst with a Date Criteria (syntax error)
    By ajetrumpet in forum Programming
    Replies: 2
    Last Post: 09-10-2010, 11:01 PM

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