Solved

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

Posted on 2014-04-02
4
203 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 51

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 51

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

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
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.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

734 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