How to easily get a list of field names in MS Access
If you have a MS Access table that has 100 fields (also known as columns), what is the easiest way to get a list of all the field names? One option is to use Database Documenter.
Access database documenter is a database tool used to document the various database objects such as tables, queries, forms, reports, macros, and so on.
Here is what you can document for a table object:
In regards to the problem we're going to solve, the documenter is a bit overkill because, in addition to the field names, the documenter also exports data types and field sizes in the file exported and the file is separated into multiple pages if there are too many things that is impractical to fit into one page. What if the only thing we'd like to get is a list of field names and nothing else? I happened to discover a way to easily accomplish this.
Export the list of field names
Suppose I need to get a list of the field names for Employees table in Northwind database. Below is the method I have been using.
Step 1: Open Northwind database. Right click on Employees table and select Export -> Excel.
Step 2: Select a destination folder and file name. Then click OK to export.
Step 3: Open the exported file Exmloyees.xlsx and highlight the first row for the column names.
Step 4: Right click on the first row and select Copy.
Step 5: Right click in cell A13 and select Paste Special.
Step 6: On the Paste Special window, tick Transpose checkbox and click OK.
Step 7: Now the field names in Employees table are pasted in column A as a list.
Even better way for large tables
You may have noticed that the data in Employees table were also exported to Excel spreadsheet. What if the table has half a million rows of data? Will that need to be exported as well? Of course not. There is a way to export only the field names without the data - duplicate Employees table but for structure only and then only export the duplicated table.
Step 1: Open Northwind database. Right click on Employees table and select Copy.
Step 2: Right click and select Paste.
Step 3: Paste the Employee table and select Structure Only. Name the new table Employees_copy.
Step 4: Export the new table Employees_copy.
Then the rest of the steps are the same as shown before. In the Excel spreadsheet, you'll only see field names and no data is exported because table Employees_copy does not contain any data. This technique is particularly useful for large Access tables.
Copyright © 2017 GeeksEngine.com. All Rights Reserved.
This website is hosted by HostGator.
No portion may be reproduced without my written permission. Software and hardware names mentioned on this site are registered trademarks of their respective companies. Should any right be infringed, it is totally unintentional. Drop me an email and I will promptly and gladly rectify it.