Results 1 to 4 of 4
  1. #1
    2 Star Lounger
    Join Date
    Jun 2001
    Posts
    146
    Thanks
    0
    Thanked 0 Times in 0 Posts

    FindFirst (2000)

    Hi,

    I'm trying to use the FindFirst method of the Recordset object but I keep running into run-time error 3251 ("Operation is not supported for this type of object."). Here is my code--the comments explain what's going on. The error hits on the line reading "rs2.FindFirst strCriteria". At that point, the variable strCriteria reads:

    "[WeekEnding] = '4/30/2004' "

    Thanks,
    Bob

    *********************************

    Public Function AppendOrUpdate()

    Dim rs1 As DAO.Recordset
    Dim rs2 As DAO.Recordset
    Dim db As DAO.DATABASE
    Dim wknd As String
    Dim strCriteria As String

    Set db = CurrentDb
    Set rs1 = db.OpenRecordset("BonusTemp")
    Set rs2 = db.OpenRecordset("Bonus")

    'Get weekending date from current record in BonusTemp table

    wknd = rs1!WeekEnding
    strCriteria = "[WeekEnding] = " & "'" & wknd & "'"

    'Search Bonus table with weekending date from BonusTemp table

    rs2.FindFirst strCriteria

    If rs2.NoMatch = True Then

    'If weekending date is not found, then run Append query
    DoCmd.OpenQuery "D - Write Bonus to Perm File -- Append"

    Else

    'If weekending date is found, then run Update query
    DoCmd.OpenQuery "D - Write Bonus to Perm File"

    End If

    End Function

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: FindFirst (2000)

    Are you sure your recordset contains any records? You cannot do a findfirst on an empty recordset. Also, if the value is truly a date and not just a date formatted string, your criteria won't match because you are using a string value.
    Charlotte

  3. #3
    2 Star Lounger
    Join Date
    Jun 2001
    Posts
    146
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: FindFirst (2000)

    That's a good point about the data type (date versus string). I ended up using the Seek method and got what I wanted.

    Thanks,
    Bob

  4. #4
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: FindFirst (2000)

    Be careful with Seek. It works on local tables but not on attached tables unless you use code to open the recordset directly against the remote database and table.
    Charlotte

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •