Search code examples
sqlms-accessodbcjet

Access 2003 - Pass Through Queries, Query Definitions and Form.Recordset (Oh My)


I am creating a pass through union query using an ODBC data source and trying to open the recordset with form!Formname.Recordset = qdf.opernRecordset. The query executes properly and returns the expected data, but when I go to execute the above code I get the error:

Error 3251 Operation is not supported for this type of object.

I know that help,concerning this error, states:

Some operations are also not supported, depending on if you are accessing a Microsoft Jet or an ODBC data source.

What is this error caused by and what is a potential workaround?


Solution

  • In VBA, use the equal sign to assign a value to a simple variable:

    MyText = "foo"
    

    But use the Set keyword when assigning to an object variable. In your case, the form's Recordset is a property rather than a variable, but that property is an object, so you still need Set:

    Set form!Formname.Recordset = qdf.OpenRecordset