Results 1 to 7 of 7
  1. #1
    boboivan is offline Advanced Beginner
    Windows 7 32bit Access 2013
    Join Date
    Dec 2015
    Posts
    65

    Finding specific date in a table

    Hello all!

    I'm trying to find in a table column the 15th day of the current month and I don't know why the following code doesn't work:



    Code:
    Dim rs As RecordsetSet 
    rs = CurrentDb.OpenRecordset("MMSA", dbOpenSnapshot, dbReadOnly)
    rs.FindFirst "StartingDate" = DateSerial(Year(Now()), Month(Now()), 15)
    If rs.NoMatch Then
    DoCmd.OpenForm "NEW"
    Else
    MsgBox "No entry"
    End If
    After running the code, there is no error returned, but just doesn't do the job.
    What am I doing wrong?

    Thx!

  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:
    rs.FindFirst "StartingDate = " & DateSerial(Year(Now()), Month(Now()), 15)

  3. #3
    boboivan is offline Advanced Beginner
    Windows 7 32bit Access 2013
    Join Date
    Dec 2015
    Posts
    65
    Thx RuralGuy!

    Still no effect

  4. #4
    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
    Is StartingDate a field in the Recordset? Try:
    rs.FindFirst "[StartingDate] = " & DateSerial(Year(Now()), Month(Now()), 15)

  5. #5
    boboivan is offline Advanced Beginner
    Windows 7 32bit Access 2013
    Join Date
    Dec 2015
    Posts
    65
    Yes, the "StartingDate" is a field in the Recordset.
    Still nothing.

    I've tried with dlookup function, but it looks only in the first record of the field.

  6. #6
    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
    I will assume that [StartingDate] is a DateTime field and you are aware that DateTime fields also contain a Time value, right? You may have to adjust for that.
    https://support.microsoft.com/en-us/kb/130514

  7. #7
    boboivan is offline Advanced Beginner
    Windows 7 32bit Access 2013
    Join Date
    Dec 2015
    Posts
    65
    Yes of course, [StartingDate] is a Date/Time field.
    I wasn't aware about time value in it. Thx!

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

Similar Threads

  1. Finding specific values in queries
    By FLindh in forum Queries
    Replies: 1
    Last Post: 07-11-2016, 04:12 AM
  2. Replies: 6
    Last Post: 06-14-2013, 05:43 PM
  3. Replies: 2
    Last Post: 12-08-2012, 10:01 AM
  4. Replies: 3
    Last Post: 07-18-2012, 10:13 PM
  5. A way of finding a specific record
    By degras in forum Forms
    Replies: 8
    Last Post: 02-17-2011, 10:28 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