473,473 Members | 2,159 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

View all indexes in Access table

79 New Member
Hi!
What query should I use to get all the indexes defined on a specific table? Even the ones which are defined on multiple columns.
Thanks.
May 22 '07 #1
6 14179
MMcCarthy
14,534 Recognized Expert Moderator MVP
Hi!
What query should I use to get all the indexes defined on a specific table? Even the ones which are defined on multiple columns.
Thanks.
I'm not sure what you mean by a query. You can find the indexes on any table by opening the table in design view and clicking indexes on the view menu.
May 25 '07 #2
ADezii
8,834 Recognized Expert Expert
Hi!
What query should I use to get all the indexes defined on a specific table? Even the ones which are defined on multiple columns.
Thanks.
Expand|Select|Wrap|Line Numbers
  1. Dim db As DAO.Database
  2. Dim tdf As DAO.TableDef
  3. Dim idx As DAO.Index
  4. Dim fld As DAO.Field
  5.  
  6. Dim strField As String
  7.  
  8. Set db = CurrentDb()
  9. Set tdf = db.TableDefs("tblEmployee")
  10. Set rst = db.OpenRecordset("tblEmployee", dbOpenTable)
  11.  
  12. ' List values for each index in the collection.
  13. For Each idx In tdf.Indexes
  14.   ' The index object contains a collection of fields,
  15.   ' one for each field the index contains.
  16.   Debug.Print
  17.   Debug.Print "Index: " & idx.Name
  18.   Debug.Print "==========================="
  19.  
  20.     For Each fld In idx.Fields
  21.       Debug.Print "Field Name: " & fld.Name
  22.     Next fld
  23.     Debug.Print
  24. Next idx
May 27 '07 #3
JConsulting
603 Recognized Expert Contributor
Expand|Select|Wrap|Line Numbers
  1. Dim db As DAO.Database
  2. Dim tdf As DAO.TableDef
  3. Dim idx As DAO.Index
  4. Dim fld As DAO.Field
  5.  
  6. Dim strField As String
  7.  
  8. Set db = CurrentDb()
  9. Set tdf = db.TableDefs("tblEmployee")
  10. Set rst = db.OpenRecordset("tblEmployee", dbOpenTable)
  11.  
  12. ' List values for each index in the collection.
  13. For Each idx In tdf.Indexes
  14.   ' The index object contains a collection of fields,
  15.   ' one for each field the index contains.
  16.   Debug.Print
  17.   Debug.Print "Index: " & idx.Name
  18.   Debug.Print "==========================="
  19.  
  20.     For Each fld In idx.Fields
  21.       Debug.Print "Field Name: " & fld.Name
  22.     Next fld
  23.     Debug.Print
  24. Next idx
Hey ADezii, is the Recordset part there in case you want to output to a table?
J
May 27 '07 #4
ADezii
8,834 Recognized Expert Expert
Hey ADezii, is the Recordset part there in case you want to output to a table?
J
No, It's a lot simpler than that - code line that is not required (LOL). Thanks for the catch.
May 27 '07 #5
JConsulting
603 Recognized Expert Contributor
No, It's a lot simpler than that - code line that is not required (LOL). Thanks for the catch.
shhh, I won't tell...I actually stole your small routine. I have a use for it myself! Good work btw. Thx.
J
May 27 '07 #6
ADezii
8,834 Recognized Expert Expert
shhh, I won't tell...I actually stole your small routine. I have a use for it myself! Good work btw. Thx.
J
Anything that you can possibly find of interest that I post, please feel free to help yourself to. At least I now know that 'ALL' my work is not in vain! BTW, thanks for the compliment.
May 27 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: WertmanTheMad | last post by:
MVP's and the like I am looking for suggestions , confirmation Let me start by saying bar none, performance is paramount with the queries to be retured off this view/table query. To that...
4
by: robert | last post by:
my colleagues are convinced that having more than an index or two destroys performance on their batch runs. could be. i don't have the data, and i'm wondering whether there might be some...
4
by: xeqister | last post by:
Greetings, I would like to know whether there is a way to estimate/calculate the view table size in DB2. As what I understand, view is just a logical table and we cannot simply calculate the size...
4
by: WindAndWaves | last post by:
Hi Everyone Is there anyone who has some sound rules of thumb for using indexes. I see that, for example, access automatically adds them to linked tables, but I feel, they are probably of more...
5
by: Bruce Rusk | last post by:
I have a question about indexing multiple fields and whether it's redundant to index the individual fields separately. As I understand it, if there is an index on two fields, say idxFullName...
3
by: joshsackett | last post by:
I am having a problem with indexes on specific tables. For some reason a query that runs against a view is not selecting the correct index on a table. I run the same query against the table...
2
by: Shirley | last post by:
We are running DB2 on iSeries V5R2. Using AQUA DATA STUDIO with a connection to our iSeries, I created a view using SQL and I am trying to create an index on this view using the code below. ...
14
by: Jeff | last post by:
This is the first time that I remember ever having too many indexes on a table, but it has happened. I have en employees table and store in many places, on tables, the id of the employee that...
16
by: UDBDBA | last post by:
Hi All: I need some clarification on a MERGE statement. The database is on V8 FP12 (AIX) 64bit. The source table is tableA. The target is a View "FACT" with UNION ALL because of the 512 Gig...
10
by: lesperancer | last post by:
you start with a small application in access97, then you have more modules and more... and you reach the point where tables like 'item' and 'employee' reach the limit and you know there's more...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.