use an index on a table

  • Thread starter Thread starter Herman
  • Start date Start date
H

Herman

Guest
In a table (tblMnthNr) there are 3 indexes, the third named 'MonthNr'.
There are at least two fields in the table: MnthNr and Days
Every time VBA reports that rs.Index is not available for this type object (error 3251). The construction is (with MndSel as String for the Seek):

Dim IndexNaam As String
Dim strCntD as String
Dim rs As Recordset
Dim db As Database

Set db = CurrentDb

Set rs = db.OpenRecordset("tblMnthNr")

IndexNaam = "MonthNr"
rs.Index = IndexNaam <= here stops the run.
rs.Seek "=", MndSel
strCntD = rs!Days

How can I VBA let handle it in the right way?
 
Well, I see 2 possible errors.

1) rs.Index = IndexNaam <= here stops the run.

If you're trying to set rs.Index = IndexNaam then you need to use this procedure

With rs
.edit
.Index = IndexNaam
.update
End With

2) Or do you want the string value IndexNaam to equal the field value? Then this should be written:

IndexNaam = rs.Index


HTH
 

Users who are viewing this thread

Back
Top Bottom