• Problem with FindFirst (Access 2003)

    Author
    Topic
    #442780

    I am stumped with the following code:

    Private Sub Form_Open(Cancel As Integer)

    Dim db As DAO.Database
    Dim rs As DAO.Recordset
    Dim intCounter As Integer
    Dim strCounter As String

    ‘On Error GoTo Error_Form_Open

    Set db = CurrentDb
    Set rs = db.OpenRecordset(“tblTransactions”)

    intCounter = Forms!frmTransactions!txtTransactionSelected

    rs.FindFirst (“TransactionID = ” & Str(intCounter))

    It fails on the FindFirst line with the error message Runtime error 3251 Operation is not supported for this type of object.

    This proc runs when an unbound editing form opens. It needs to collect its data from the record referenced in the variable txtTransactionSelected on the form frmTransactions. intCounter is picking up the expected transaction number. So why does FindFirst fail?

    Any help would be appreciated.

    David

    Viewing 0 reply threads
    Author
    Replies
    • #1066722

      You haven’t specified the recordset type, and unfortunately, the default is dbOpenTable, and this doesn’t support FindFirst. Change the line that opens the recordset to

      Set rs = db.OpenRecordset(“tblTransactions”, dbOpenDynaset)

      • #1066799

        Good morning Hans

        As ever, many thanks – this works as I want.

        David

    Viewing 0 reply threads
    Reply To: Problem with FindFirst (Access 2003)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: