Search ColumnName

ravikode

New Member
Joined
Oct 10, 2003
Messages
27
I have a columnName and I want to know in which table and query the column resides in my Access database
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
You can try something like following (assuming you know how to use this code in a VBA module):

Code:
Sub RunMe()
Dim fldname As String
Dim fld As Object
Dim tbl As Object
Dim qry As Object
    
    'Set Field Name to look for in the database objects
    fldname = "Field1"
    For Each tbl In CurrentDb.TableDefs
        If tbl.Attributes = 0 Then
            For Each fld In tbl.fields
                If fld.Name = fldname Then
                    MsgBox fld.Name & " resides in """ & tbl.Name & """"
                End If
            Next fld
        End If
    Next tbl
    For Each qry In CurrentDb.QueryDefs
        For Each fld In qry.fields
            If fld.Name = fldname Then
                MsgBox fld.Name & " resides in """ & qry.Name & """"
            End If
        Next fld
    Next qry
End Sub

Suat
 
Upvote 0

Forum statistics

Threads
1,221,569
Messages
6,160,557
Members
451,656
Latest member
SBulinski1975

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