Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2004
    Posts
    15

    Angry Unanswered: Setting index for DAO Recordset - WHAT AM I DOING WRONG??????

    I have a table called tblNewEmails. The primary key is an long integer field called "Reference" which I want to use as the index with the seek method. Here is my code.

    Dim dbs As DAO.Database
    Dim rst As DAO.Recordset
    Set dbs = CurrentDb
    Set rst = dbs.OpenRecordset("tblNewEmails", dbOpenTable)
    rst.Index = "Reference"
    rst.Seek "=", 8000511


    I get the error "Reference is not an index in this table" at the second last line. WHAT AM I DOING WRONG???????? PLEASE HELP!

  2. #2
    Join Date
    Aug 2003
    Location
    Delft, The Netherlands (EU)
    Posts
    447

    Re: Setting index for DAO Recordset - WHAT AM I DOING WRONG??????

    You have to specify the index name, not the column's name! You can look up the index name in the table's index collection.
    Make everything as simple as possible, but not simpler! - A. Einstein
    DB Problems? DB Explorer, BTrieve Re-engineering, DB Conversions & ETL? Conversion Tool

  3. #3
    Join Date
    Mar 2004
    Posts
    15

    Re: Setting index for DAO Recordset - WHAT AM I DOING WRONG??????

    Originally posted by DoktorBlue
    You have to specify the index name, not the column's name! You can look up the index name in the table's index collection.

    Yes I know. The thing that was confusing me was that every index in the table's index collection has the same name as the indexed field in the table EXCEPT THE PRIMARY KEY whose name in the index collection is apparently "PrimaryKey", not "Reference" or whatever the field is named. So I had 3 indexed fields in my table...Reference(the key), DateNo, and Sender. I assumed the names in the Index collection would be "Reference", "DateNo", and "Sender" but they are "PrimaryKey", "DateNo", and "Sender". Thanks.

  4. #4
    Join Date
    Mar 2004
    Location
    belgium
    Posts
    290
    and don´t forget that by changing the fieldname in table design the indexname doesn´t change !

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •