Solved

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

Posted on 2014-04-02
4
192 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 49

Accepted Solution

by:
Rgonzo1971 earned 500 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 49

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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

Suggested Solutions

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
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…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

803 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