All Tables Query


Is there a way in Access to do a search on all tables? I want to write a query that gives me all the table names that have the column equal  Program. In oracle I would be able to do this.


Select table_name from all_tables where column_name = "Program";

Thank you
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Hello Michele.
this function (run in an immediate widnow) will display all the tables where a column name exists in your database.

to use it, just type :
? FindColumnsInTablesRS("Program")
: in the Immediate window and press enter.

Public Function FindColumnsInTablesRS(inColumnName As String)

    Dim T As DAO.TableDef
    Dim F As DAO.Field
    Dim X As Integer
    For Each T In CurrentDb.TableDefs
        For X = 0 To T.Fields.Count - 1
            Set F = T.Fields(X)
            If UCase(inColumnName) = ucase(F.Name) Then
                Debug.Print T.Name
            End If
        Next X
    Next T
End Function


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Or this if you want a string with all fields:
Sub getfields()

Dim db As Database
Dimtbl As TableDef

  Set db = CurrentDb
   For Each tbl In db.TableDefs
     For i = 0 To tbl.Fields.Count - 1
         If tbl.Fields(i).Name = "Program" Then
         strNames = strNames & tbl.Name & "." & tbl.Fields(i).Name & ","
         End If
    strNames = Left(strNames, Len(strNames) - 1)
End Sub
I think RD got it.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.