Results 1 to 5 of 5
  1. #1
    2 Star Lounger
    Join Date
    Mar 2006
    Posts
    195
    Thanks
    0
    Thanked 0 Times in 0 Posts

    remove index (Access 2000)

    My function to remove index shows the error Item not found. Did i write it wrong?it is as follows and i call it with RemoveIndex "Pricelist", "code"
    Sub RemoveIndex(strTable As String, strIndex As String)
    Dim dbs As DAO.Database
    Dim tdf As DAO.TableDef
    Set dbs = CurrentDb
    Set tdf = dbs.TableDefs(strTable)
    tdf.Indexes.Delete strIndex
    Set tdf = Nothing
    Set dbs = Nothing
    End Sub
    With the above function i want to delete the index in the field code.The field code has an indexed property set to Yes(Duplicates OK ) and i want to remove it. Why do i receive the error item not found ?

  2. #2
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: remove index (Access 2000)

    Why do you wish to do this in code?

    Your index name is CodeIdx not code.

  3. #3
    2 Star Lounger
    Join Date
    Mar 2006
    Posts
    195
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: remove index (Access 2000)

    Thanks for thr reply. Because this is a [art of a larger function performing chain of actions.
    I have tried with
    RemoveIndex "Pricelist", "CodeIdx "

    but i received again the same error, namely " item not found in the collection".
    Did i write it correct ?

  4. #4
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: remove index (Access 2000)

    You should check if the index exists.

    If you push the button twice on the form, the first time through deletes the index and the second time through it throws up the error because the index in fact does not exist because it has been deleted.

  5. #5
    2 Star Lounger
    Join Date
    Mar 2006
    Posts
    195
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: remove index (Access 2000)

    Dear Pat

    you are right!!!! Obviously i ave pushed the button twice.Thank you,
    so grateful for that

Posting Permissions

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