access 20003 code not working in access 2016 RRS feed

  • Question

  • Message Operation is not supported for this type of object., and it highlights on WRK_REC_SET.Index = "PrimaryKey"

        Dim WRK_CONTROL     As Control
        Dim WRK_REC_SET     As Recordset
        Dim WRK_DB          As Database
        Set WRK_DB = CurrentDb
        Set WRK_REC_SET = WRK_DB.OpenRecordset("SM_TBL_LBL")
        WRK_REC_SET.Index = "PrimaryKey"
        For J = 0 To WRK_CUR_FORM.Count - 1
            Set WRK_CONTROL = WRK_CUR_FORM(J)
            If Mid(WRK_CONTROL.Name, 1, 3) = "LAB" Then
                WRK_REC_SET.Seek "=", WRK_CUR_FORM.Name, WRK_CONTROL.Name
              If Not WRK_REC_SET.NoMatch Then
                If GLOBAL_LANGUAGE = "ARABIC" Then
                    If Not IsNull(WRK_REC_SET!A_DESC) Then
                        WRK_CONTROL.Caption = Trim(WRK_REC_SET!A_DESC)
                    End If
                    If Not IsNull(WRK_REC_SET!E_DESC) Then
                        WRK_CONTROL.Caption = Trim(WRK_REC_SET!E_DESC)
                    End If
                End If
              End If
            End If

    End Sub

    Wednesday, January 4, 2017 8:08 AM

All replies

  • Hi,

    usually this happens if you try to use Index (preparing Seek) for a linked table.

    Index and Seek only work with DAO recordsets of type Table (not Dynaset or Snapshot). In your Set line for the recordset you didn't specify the recordset type. So you get the standard type. For a locale table this is Table, for linked tables it is Dynaset.

    There are 2 workarounds. Either you use FindFirst instead of Seek or if you want to stick to Seek you can open the linked table as recordset of its origin database and specify a Table type recordset:

    Dim db As DAO.Database
    Dim rs As DAO.Recordset
    Set db = DBEngine.Workspaces(0).OpenDatabase("External_DB")
    Set rs = db.OpenRecordset("
    SM_TBL_LBL", dbOpenTable)


    Wednesday, January 4, 2017 11:14 AM