Code changes from this code to print queries necessary to print out macro definitions

  • Thread starter Thread starter Newbie
  • Start date Start date
N

Newbie

In searching the web for a method to print out macro definitions, I
found this code from allen Browne to print out query definitions. Is
there a similar way to print out macros?

Public Function ShowAllQueries()
Dim db As DAO.Database
Dim qdf As DAO.QueryDef

Set db = CurrentDb()
For Each qdf In db.QueryDefs
Debug.Print qdf.Name, qdf.SQL
Next
End Function

In other words, does DAO or some other object expose something like a
MacroDef, similar to a QueryDef?

Thank you.
 
I tried Arvin Meyer's code and it worked fine. I added tables (which was
missing) but it fails when it runs:

Set cnt = dbs.Containers("tables")
For Each doc In cnt.Documents
Application.SaveAsText acTable, doc.name, "D:\Document\" & doc.name &
".txt"
Next doc

The message is this: The Object Type argument for the action or method is
blank or invalid. Is dbs.Containers("tables") invalid? Will anthing work
here for tables?

Thanks

Bob
 
Didya ever stop to think there was a reason why tables weren't included? <g>

What do you want to see for tables? A list of table names and the fields
within them?

Public Function ShowAllQueries()
Dim db As DAO.Database
Dim tdf As DAO.TableDef
Dim fld As DAO.Field

Set db = CurrentDb()
For Each tdf In db.TableDefs
Debug.Print tdf.Name
For Each fld in tdf.Fields
Debug.Print " " & fld.Name
Next fld
Debug.Print
Next tdf

End Function

If something else, post back with details.
 
Doug

yea, I figured tables were probably excluded for a reason, but .......

Thanks for your code..It (of course) works..is there a way I can add the
validation rules and the "required" indicator and the data type?

Thanks a lot

Bob
 
Both the TableDef and Field objects have a ValidationRule property that you
can refer to the same way as the code below refers to the Name property.
It'll be a ZLS (zero-length string, or "") if no rule exists.

The Field object has a Required property that will be True or False.

The Field object also has a Type property that will indicate the data type
of the field. Unfortunately, it returns a number: you'd have to write a
function that translates that number to the appropriate data type name.

Rather than re-invent the wheel, though, you might be interested in some of
the options Jeff Conrad lists at
http://home.bendbroadband.com/conradsystems/accessjunkie/doctable.html
 
Back
Top