ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Access queries/tables (https://www.excelbanter.com/excel-discussion-misc-queries/97541-access-queries-tables.html)

Naz

Access queries/tables
 
Hello all,

How can i get a list of the table and querie names in an access database
into a spreadsheet?
--

_______________________
Naz,
London

Kevin B

Access queries/tables
 
I use the following subroutine to produce document lists for my various
databases.

I have a table named tblDocuments with a 2 columns, one for the document
name and another for its container. The code opens the table as recordset
object and the uses a FOR loop to loop through each container, and within
each container, each document, posting the document name in the first field
and the container name in the second. You could then export the table to
Excel or query it from Excel using MS Query.

Sub ContainerContents()

Dim dbs As DAO.Database
Dim rst As DAO.RecordSet
Dim con As Container
Dim doc As Document
Dim strDocName As String
Dim strConName As String

Set dbs = CurrentDb()
Set rst = dbs.OpenRecordset("tblDocuments")

For Each con In dbs.Containers
strConName = con.Name
For Each doc In con.Documents
strDocName = doc.Name
With rst
.AddNew
.Fields(0).Value = strDocName
.Fields(1).Value = strConName
.Update
End With
Next doc
Next con

rst.Close

Set dbs = Nothing
Set rst = Nothing
Set con = Nothing
Set doc = Nothing

End Sub
--
Kevin Backmann


"Naz" wrote:

Hello all,

How can i get a list of the table and querie names in an access database
into a spreadsheet?
--

_______________________
Naz,
London



All times are GMT +1. The time now is 08:35 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com