Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / February 2008

Tip: Looking for answers? Try searching our database.

obtain list of fields

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
J. Freed - 25 Feb 2008 21:36 GMT
I've been asked to generate a list of all the fields used within an mdb for
certain selected tables. Aside from going through each query and manually
inspecting them, is there a programmatic way to do this? (I've examined the
hidden system tables but they have not been helpful).

TIA.
fredg - 25 Feb 2008 22:06 GMT
> I've been asked to generate a list of all the fields used within an mdb for
> certain selected tables. Aside from going through each query and manually
> inspecting them, is there a programmatic way to do this? (I've examined the
> hidden system tables but they have not been helpful).
>
> TIA.

First youstate "all the fields used within an mdb" then you state
"going through each query". Which is it?

Anyway look in
Tools + Analyze + Documenter
Signature

Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail

Daniel Pineault - 26 Feb 2008 02:14 GMT
Try these

'---------------------------------------------------------------------------------------
' Procedure : listTableFields
' Author    : CARDA Consultants Inc.
' Website   : http://www.cardaconsultants.com
' Purpose   : Return a listing of all the fields (column names) of a give
table
' Copyright : The following code may be used as you please, but may not be
resold, as
'             long as the header (Author, Website & Copyright) remains with
the code.
'
' Input Variables:
' ~~~~~~~~~~~~~~~~
' strTblName - Name of the table to list the fields of.
'
' Revision History:
' Rev       Date(yyyy/mm/dd)        Description
'
**************************************************************************************
' 1         2007-June-01            Initial Release
'---------------------------------------------------------------------------------------
Function listTableFields(strTblName As String) As String
On Error GoTo listTableFields_Error
   Dim db As DAO.Database
   Dim tdfld As DAO.TableDef
   Dim fld As Field
   
   Set db = CurrentDb()
   Set tdfld = db.TableDefs(strTblName)
   For Each fld In tdfld.Fields    'loop through all the fields of the tables
       Debug.Print fld.Name
   Next

   Set tdfld = Nothing
   Set db = Nothing
If Err.Number = 0 Then Exit Function

listTableFields_Error:
   MsgBox "MS Access has generated the following error" & vbCrLf & vbCrLf &
"Error Number: " & _
   Err.Number & vbCrLf & "Error Source: listTableFields" & vbCrLf & _
   "Error Description: " & Err.Description, vbCritical, "An Error has
Occured!"
   Exit Function
End Function

'---------------------------------------------------------------------------------------
' Procedure : listQueryFields
' Author    : CARDA Consultants Inc.
' Website   : http://www.cardaconsultants.com
' Purpose   : Return a listing of all the fields (column names) of a give
Query
' Copyright : The following code may be used as you please, but may not be
resold, as
'             long as the header (Author, Website & Copyright) remains with
the code.
'
' Input Variables:
' ~~~~~~~~~~~~~~~~
' strQryName - Name of the query to list the fields of.
'
' Revision History:
' Rev       Date(yyyy/mm/dd)        Description
'
**************************************************************************************
' 1         2007-June-01            Initial Release
'---------------------------------------------------------------------------------------
Function listQueryFields(strQryName As String) As String
On Error GoTo listQueryFields_Error
   Dim db As DAO.Database
   Dim qryfld As DAO.QueryDef
   Dim fld As Field
   
   Set db = CurrentDb()
   Set qryfld = db.QueryDefs(strQryName)
   For Each fld In qryfld.Fields    'loop through all the fields of the Query
       Debug.Print fld.Name
   Next

   
   Set qryfld = Nothing
   Set db = Nothing
If Err.Number = 0 Then Exit Function

listQueryFields_Error:
   MsgBox "MS Access has generated the following error" & vbCrLf & vbCrLf &
"Error Number: " & _
   Err.Number & vbCrLf & "Error Source: listQueryFields" & vbCrLf & _
   "Error Description: " & Err.Description, vbCritical, "An Error has
Occured!"
   Exit Function
End Function

Signature

Hope this helps,

Daniel Pineault
If this post was helpful, please rate it by using the vote buttons.

> I've been asked to generate a list of all the fields used within an mdb for
> certain selected tables. Aside from going through each query and manually
> inspecting them, is there a programmatic way to do this? (I've examined the
> hidden system tables but they have not been helpful).
>
> TIA.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.