Link to home
Start Free TrialLog in
Avatar of tpigielski
tpigielski

asked on

Microsoft Access "Operation is not supported for this type of object" - Error 3251

I've included a snipit of code here that is giving me a problem.  When it gets to the "findfirst" statement below, I get the error "operation is not supported for this type of object".  I've tried multiple things, but cannot seem to get around this problem.

Thanks in advance for your help.

Tom

------------------------------------------------------------------------------------------
Dim rec4 As DAO.Recordset
Dim Criteria As String

Set rec4 = CurrentDb.OpenRecordset("course")

Dim course As String

    With rec3
   
        While parse(water, course) = vbYes
            .AddNew
                ![Student_ID] = Student_ID
                rec4.FindFirst "Course_No = " & course       ' this line causes the problem
                ![course_no] = rec4![course_id]
            .Update
           
        Wend
Avatar of DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
Flag of United States of America image

What is rec3 ?
Same as Mx above.

Plus
where is Course getting it's value from?
Plus
you have defined Course as string so
if course_no is defined as text  then the syntax should be..

rec4.FindFirst "Course_No = '" & course & "'"
ASKER CERTIFIED SOLUTION
Avatar of Jeffrey Coachman
Jeffrey Coachman
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of tpigielski
tpigielski

ASKER

I fully appreciate the comments made here, especially the ones by Jeff.  I truly do adhere to better standards when creating applications.  I modified (shortened) the code to include here, and also changed some of the names to try and make it simpler, and in the process, made it more confusing.  I truly apologize.

The problem, it turns out, was with how the table was opened to enable the "find" capability.

I had used the following:

Set rec2 = CurrentDb.OpenRecordset("course")

instead of the following:

Set rec4 = CurrentDb.OpenRecordset( _
        "SELECT course_id, Course_No" & _
        " FROM Course", _
        dbOpenSnapshot)

This is what caused the problem.

Tom