Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2014-04-02
4
Medium Priority
?
213 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 52

Accepted Solution

by:
Rgonzo1971 earned 2000 total points
ID: 39972199
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
ID: 39972226
I get a runtime error "Object required" on line:

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

Expert Comment

by:Rgonzo1971
ID: 39972258
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
ID: 39972267
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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

722 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