Solved

How to change a table's 'Indexed' from Yes to No in VBA

Posted on 2014-04-02
4
181 Views
Last Modified: 2014-09-11
I need to drop the Primary Key AND remove indexing from the Primary Key field, and have used the following command successfully in the past:

DoCmd.RunSQL "DROP INDEX PrimaryKey ON tbAccounts_WithDuplicatesForReports"

This command NOW drops the PrimaryKey, but the 'Indexed' property remains "Yes (No Duplicates)", but when I used it before, this command also changed the 'Indexed' property to "No".

Recently I have had to reconstruct the table, so something might be different from what it was before, but I was careful to copy all field names from the original, and the names are identical.
0
Comment
Question by:David_W_R
  • 2
  • 2
4 Comments
 
LVL 48

Accepted Solution

by:
Rgonzo1971 earned 500 total points
Comment Utility
HI,

pls try
    Set db = CurrentDb
    db.TableDefs("tbAccounts_WithDuplicatesForReports").Indexes.Delete ("PrimaryKey")

Open in new window

Regards
0
 

Author Comment

by:David_W_R
Comment Utility
I get a runtime error "Object required" on line:

db.TableDefs("tbAccounts_WithDuplicatesForReports").Indexes.Delete ("PrimaryKey")
0
 
LVL 48

Expert Comment

by:Rgonzo1971
Comment Utility
Hi,

Could you explore the object with Locals

Set Obj = db.TableDefs("tbAccounts_WithDuplicatesForReports")

Open in new window

Regards
0
 

Author Comment

by:David_W_R
Comment Utility
I tried it again without the parentheses around "PrimaryKey" thus:

db.TableDefs("tbAccounts_WithDuplicatesForReports").Indexes.Delete "PrimaryKey"



and it ran, removing the Primary Key, but still left the 'Indexed' property of this field as "Yes (No Duplicates)"

Is there a way to selectively change the 'Indexed' property of a (text) field (to "No") ?
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now