Unable to run macro

G

Guest

Greetings,
I am trying to execute the following code in MS Access 2000 (in a
separate module sheet). When I attempt to run this code, nothing happens
(nor does this routine appear in the list of available macros to run). If I
compile the modules (via "Debug", "Compile ..."), they seem to compile fine.
Could I be missing a reference? The references I currently have checked are
the following: Visual Basic for Applications, Microsoft Access 9.0 Object
Library, OLE Automation, Microsoft DAO 3.6 Object Library, Microsoft Windows
Common Controls 6.0 (SP6), Microsoft Outlook 9.0 Object Library, Microsoft
ADO Ext. 2.8 for DDL and Security, Microsoft ActiveX Data Objects Recordset
2.8 Library, and Microsoft ActiveX Data Objects 2.1 Library.

Any suggestions? Thanks in advance!

Sherwood



Sub ListAccessTables(strDBPath As String)
Dim catDB As ADOX.Catalog
Dim tblList As ADOX.Table

Set catDB = New ADOX.Catalog
' Open the catalog.
catDB.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=" & strDBPath

' Loop through all the tables, but not queries,
' and print their names and types.
For Each tblList In catDB.Tables
If tblList.Type <> "VIEW" Then
Debug.Print tblList.Name & vbTab & tblList.Type
End If
Next

Set catDB = Nothing
End Sub
 
B

Brendan Reynolds

In Access, macros and VBA code are two very different things. Your code
doesn't show up in the list of available macros because it is not a macro.
For testing purposes, you can run your procedure from the Immediate window
(press Ctrl+G to open the Immediate window) simply by entering the name of
the sub followed by any required arguments, e.g.

ListAccessTables "C:\SomeFolder\SomeFile.mdb"

--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top