Newbie to Access - Extract field name from ALL tables?

im2bz2p345

Board Regular
Joined
Mar 31, 2008
Messages
229
Hi all,

I am a total newbie to Access, so please go easy on me and explain things step by step.

See my screenshot below. What I'm trying to do is extract the field names (i.e. HospProvId, EPI_no, etc) from ALL the tables in my database at once. You can see my table field names on the left and I have about 50 tables total.

What I'm trying to do is find a specific field and I want to be able to search all the field names/columns where data actually populates.

Does anyone know if this is possible? If so, can someone walk me through the steps? I know very little in Access.

Thanks all,

~ Im2bz2p345 :)


55ef1b1aa7575.png
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
in a MODULE, paste this code, then type Ctl-G
put cursor in the sub, click PLAY button (run sub button)
all tables and fields will write to "C:\folder\tables.txt".
change it if you wish.

Code:
Public Sub PrintAllFieldsInAllTbls()
Dim fld  As Field
Dim tdf As TableDef
Dim vFILE


vFILE = "C:\folder\tables.txt"


Open vFILE For Output As #1
For Each tdf In CurrentDb.TableDefs
    With tdf
        Print #1, "table: " & tdf.Name
        Print #1, "-------------"
       For Each fld In .Fields
            Debug.Print fld.Name, TypeName(fld.Type)
       Next
    End With
Next
Close 1


Set tdf = Nothing
Set fld = Nothing
End Sub
 
Upvote 0
Thanks ranman256.

Your solution provided me with all the table names in a text file (which I didn't need), but when I hit Ctrl+G to open up the Immediate window and ran your code, it listed all the field names down below in the Immediate window (which is really what I was after).

I just copied them from the Immediate window on the bottom of the Access and put them into a text file. Then I opened up Excel and imported the data from the text file.

I now have all the field names! Thank you so much for all of your help.

~ Im2bz2p345 :)
 
Upvote 0

Forum statistics

Threads
1,221,845
Messages
6,162,350
Members
451,760
Latest member
samue Thon Ajaladin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top