By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,493 Members | 1,233 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,493 IT Pros & Developers. It's quick & easy.

GENERATE FIELD LIST FROM A QUERY?

P: n/a
QUESTION for the experts out there :)

Is it possible to write a query that would list the datafields by each table
in a database? How would I do that?!?!

TIA
Joe
Nov 12 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"Joe User" <jo*@user.com> wrote in news:bs**********@tribune.mayo.edu:
QUESTION for the experts out there :)

Is it possible to write a query that would list the datafields by each
table in a database? How would I do that?!?!

TIA
Joe


Assuming a modern version of Access:

Sub GetColumnNames()
Dim r As ADODB.Recordset
Dim Table As String
Set r = CurrentProject.Connection.OpenSchema(adSchemaColum ns)
With r
Do While Not .EOF
If .Fields("TABLE_NAME") <> Table Then
Debug.Print .Fields("TABLE_NAME").Value
End If
Debug.Print , .Fields("COLUMN_NAME").Value
Table = .Fields("TABLE_NAME").Value
.MoveNext
Loop
End With
End Sub

This gives the columns of queries too. You will have to do some filtering
to get just your tables.

--
Lyle
(for e-mail refer to http://ffdba.com/contacts.htm)
Nov 12 '05 #2

P: n/a
DFS
"Joe User" <jo*@user.com> wrote in message
news:bs**********@tribune.mayo.edu...
QUESTION for the experts out there :)

Is it possible to write a query that would list the datafields by each table in a database? How would I do that?!?!

TIA
Joe

Don't know about a query, but this code will give you a list of tables and
fields

dim i,j
dim db as database
set db = currentdb()

For i = 0 To db.TableDefs.Count - 1
For j = 0 To db.TableDefs(i).Fields.Count - 1
MsgBox "Table: " & db.TableDefs(i).Name & " Field:" &
db.TableDefs(i).Fields(j).Name
Next j
Next i


Nov 12 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.