index problem

  • Thread starter Thread starter Marcello Lenci
  • Start date Start date
M

Marcello Lenci

Someone would tell me why the following code:
Dim rst As DAO.Recordset
Set rst = Currentdb.Openrecordset("Norme")
rst.Index="NormeLink"

give me the error:
the operation is not supported by this kind of object ?
Tanks
 
Marcello,

I can reproduce the error that you report if I try to open a Linked Table
using the code you supplied. According to VBA Help: The default recordset
type created for a linked table is a Dynaset, and the Index property is not
available for that recordset type.

Perhaps if you will tell us what it is that you want to accomplish, other
solution(s) may be available.
 
Someone would tell me why the following code:
Dim rst As DAO.Recordset
Set rst = Currentdb.Openrecordset("Norme")
rst.Index="NormeLink"

give me the error:
the operation is not supported by this kind of object ?
Tanks

By default, OpenRecordset opens a "Dynaset" type recordset. The Index
property applies only to Table type recordsets. If Norme is a local
(not linked) table you can use

Set rst = CurrentDb.OpenRecordset("Norme", dbOpenTable)

If it's not a local table and you want to use the Index property (in
order to use the Seek method, about the only context for which the
Index is useful), you'll need to set a database reference to the
actual database containing the table, rather than using CurrentDb.
 
Thanks for your help
I need to seek the records who respond to a criteria and erase them
 
A Delete Query will do what you want. The code (untested) would look
something like the following:

Dim rst As DAO.Recordset
Currentdb.Execute "DELETE * from Norme WHERE << insert your criteria >>",
dbFailOnError

If you are unfamiliar with Delete Queries or Action Queries in general, I
would urge you to open Access Help and, in the Answer Wizard, enter
delete query
 
Back
Top