Table Names in DB

dtaylor

Active Member
Joined
Mar 21, 2002
Messages
379
Hello All,

Is there a way to obtain all the table/query names in a database?


Thanks

Dan
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Hi Dan,

Try this :

Sub GetNames()
Dim i As Integer
For i = 0 To CurrentDb.TableDefs.Count - 1
If CurrentDb.TableDefs(i).Attributes = 0 Then
Debug.Print CurrentDb.TableDefs(i).Name
End If
Next i
For i = 0 To CurrentDb.QueryDefs.Count - 1
If Not Left(CurrentDb.QueryDefs(i).Name, 1) = "~" Then
Debug.Print CurrentDb.QueryDefs(i).Name
End If
Next i
End Sub

This will print Visible table and query names in to immediate window.

I hope it helps.

Regards
Suat
 
Upvote 0

Forum statistics

Threads
1,221,508
Messages
6,160,222
Members
451,631
Latest member
coffiajoseph

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