Results 1 to 4 of 4
  1. #1
    Join Date
    May 2004
    Location
    New York State
    Posts
    1,178

    Unhappy Unanswered: .FindFirst not working in DAO

    I have the following code snippet that bombs:

    Code:
        Dim Rst As DAO.Recordset, strCrit As String
        
        Set Rst = CurrentDb.OpenRecordset("CustItemList", dbopentable)
        
        strCrit = "Custno = '" & Me.custno & "'"
        If Nz(Me.item, " ") > " " Then
            strCrit = strCrit + " And Item = '" & Me.item & "'"
        End If
        With Rst
            .FindFirst strCrit
            If Not .NoMatch Then
                . . .
    The bolded, underlined line bombs. I get an error message: Run-time error '3251' Operation is not supported for this type of object.

    .FindFirst doesn't work on a DAO recordset opened as a dbOpenTable!? Since when???? I also noticed something else that's strange. Why didn't VBA capitalize the O and T in dbOpenTable? Usually that's a hint that something's wrong. But what?

    CustItemList is a stand-alone table, not a link.

    I'm using A 02.

    Thanks,
    Sam

    ps. Printing out strCrit in the Immediate screen gives me

    Custno = 'TMCA15' And Item = '2145'
    which is both what I want and syntactically correct for SQL.
    Last edited by Sam Landy; 07-19-07 at 16:54.

  2. #2
    Join Date
    May 2004
    Location
    New York State
    Posts
    1,178
    My goof. I read the help for FindFirst, and it only works on dynaset and snapshot types.

    Bury head in sand. Go ahead!

    I made the obvious change and it works.

    Sorry for the bother,

    Sam

  3. #3
    Join Date
    May 2012
    Posts
    1
    Just want to say thanks a million for your comments on this - you totally saved me big time on my college assignment! Peace out!

    Suggsy!

  4. #4
    Join Date
    May 2004
    Location
    New York State
    Posts
    1,178
    Wow! To think that I posted this almost five years ago, and it's accomplishing now! It's mind boggling.

    Thanks for the comment.

    Sam

Posting Permissions

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