How do I print the details view

D

David

When viewing the database objects screen, I can click on view/details and
see a list of my queries, their description, creation date ... etc.

How can I print the inormation shown in this view?

I have been using Print-screen but that gives me a bitmap. I want a real
printout or list to export.
 
D

David

Tried that, gives way more than I want right now.
I just neet a printout that looks like the details view.
 
G

Gary Walter

David said:
Tried that, gives way more than I want right now.
I just neet a printout that looks like the details view.
Hi David,

In addition to Van's excellent advice,
these are available through the QueryDef
collection.

For example, start a new Module.
Save it as "modUtilities"
Go into Tools/References and make sure DAO library
is selected.
Copy and paste the following code into the module.
Click on "Save"
Run Debug/Compile... to make sure code okay
(there may be word wrapping).

Then, in Immediate Window type in

?flistqueries("C:\queries.txt")

and hit Enter key.

This will save "everything you wanted to know"
about *all* queries in your db in C:\queries.txt.

Queries beginning with a "~sq_c" come from
forms (and controls) or reports.

You could add some code to ignore these.

You could also comment out all code lines
for values you don't want to see in text file.

You also could create a table to hold these
values and, instead of writing to text file, save
them to the table.

Note: property "Updateable" is *not* the same
as "This query is updateable, i.e, can open it
and edit field values."

Good luck,

Gary Walter

'***start code***
Option Explicit
Public Function fListQueries(pPath As String) As Boolean
On Error GoTo Err_fListQueries

Dim dbs As DAO.Database, qdf As DAO.QueryDef
Dim param As DAO.Parameter
Dim hfile As Long
Const conPropNotFound As Integer = 3270

'First get a new file handle
hfile = FreeFile
Open pPath For Output As hfile

Set dbs = CurrentDb

' Enumerate through QueryDefs collection.
For Each qdf In dbs.QueryDefs
With qdf
Print #hfile, "--------------------"
Print #hfile, "Name: " & .Name
Print #hfile, "Description: " & .Properties("Description")
Print #hfile, "Modified: " & .LastUpdated
Print #hfile, "Created: " & .DateCreated
Select Case .Type
Case dbQAction
Print #hfile, "Type: Action"
Case dbQAppend
Print #hfile, "Type: Append"
Case dbQCompound
Print #hfile, "Type: Compound"
Case dbQCrosstab
Print #hfile, "Type: Crosstab"
Case dbQDDL
Print #hfile, "Type: DDL"
Case dbQDelete
Print #hfile, "Type: Delete"
Case dbQMakeTable
Print #hfile, "Type: MakeTable"
Case dbQProcedure
Print #hfile, "Type: Procedure"
Case dbQSelect
Print #hfile, "Type: Select"
Case dbQSetOperation
Print #hfile, "Type: Set Operation"
Case dbQSPTBulk
Print #hfile, "Type: SPT Bulk"
Case dbQSQLPassThrough
Print #hfile, "Type: PassThrough"
Case dbQUpdate
Print #hfile, "Type: Update"

Case Else
Print #hfile, "Type: Unknown"
End Select
Print #hfile, "SQL: " & vbCrLf & vbCrLf & .SQL
For Each param In .Parameters
Print #hfile, "Parameter Name: " & param.Name
Select Case param.Type
Case dbBigInt
Print #hfile, "Parameter Type: Big Integer"
Case dbBinary
Print #hfile, "Parameter Type: Binary"
Case dbBoolean
Print #hfile, "Parameter Type: Boolean"
Case dbByte
Print #hfile, "Parameter Type: Byte"
Case dbChar
Print #hfile, "Parameter Type: Char"
Case dbCurrency
Print #hfile, "Parameter Type: Currency"
Case dbDate
Print #hfile, "Parameter Type: Date/Time"
Case dbDecimal
Print #hfile, "Parameter Type: Decimal"
Case dbDouble
Print #hfile, "Parameter Type: Double"
Case dbFloat
Print #hfile, "Parameter Type: Float"
Case dbGUID
Print #hfile, "Parameter Type: GUID"
Case dbInteger
Print #hfile, "Parameter Type: Integer"
Case dbLong
Print #hfile, "Parameter Type: Long"
Case dbLongBinary
Print #hfile, "Parameter Type: Long Binary (OLE Object)"
Case dbMemo
Print #hfile, "Parameter Type: Memo"
Case dbNumeric
Print #hfile, "Parameter Type: Numeric"
Case dbSingle
Print #hfile, "Parameter Type: Single"
Case dbText
Print #hfile, "Parameter Type: Text"
Case dbTime
Print #hfile, "Parameter Type: Time"
Case dbTimeStamp
Print #hfile, "Parameter Type: Time Stamp"
Case dbVarBinary
Print #hfile, "Parameter Type: VarBinary"

Case Else
Print #hfile, "Parameter Type: Unknown"
End Select
Next param
Print #hfile, "Updateable: " & .Updatable
Print #hfile, "Connect: " & .Connect
Print #hfile, "Returns Records: " & .ReturnsRecords

End With
NewQ: Next qdf

Close hfile
fListQueries = True

Exit_fListQueries:
Set qdf = Nothing
Set dbs = Nothing
Reset
Exit Function

Err_fListQueries:
If Err = conPropNotFound Then
Print #hfile, "Description:"
Resume Next
Else
If Err = 3078 Or Err = 91 Then
Print #hfile, "**This query has problems: " & vbCrLf & Err.Description
Resume NewQ
Else
fListQueries = False
MsgBox "Error Number: " & Err.Number & " " & Err.Description
Resume Exit_fListQueries
End If
End If
End Function
'***end code***
 
D

David

This works great. I can adapt.

Thanks


Gary Walter said:
Hi David,

In addition to Van's excellent advice,
these are available through the QueryDef
collection.

For example, start a new Module.
Save it as "modUtilities"
Go into Tools/References and make sure DAO library
is selected.
Copy and paste the following code into the module.
Click on "Save"
Run Debug/Compile... to make sure code okay
(there may be word wrapping).

Then, in Immediate Window type in

?flistqueries("C:\queries.txt")

and hit Enter key.

This will save "everything you wanted to know"
about *all* queries in your db in C:\queries.txt.

Queries beginning with a "~sq_c" come from
forms (and controls) or reports.

You could add some code to ignore these.

You could also comment out all code lines
for values you don't want to see in text file.

You also could create a table to hold these
values and, instead of writing to text file, save
them to the table.

Note: property "Updateable" is *not* the same
as "This query is updateable, i.e, can open it
and edit field values."

Good luck,

Gary Walter

'***start code***
Option Explicit
Public Function fListQueries(pPath As String) As Boolean
On Error GoTo Err_fListQueries

Dim dbs As DAO.Database, qdf As DAO.QueryDef
Dim param As DAO.Parameter
Dim hfile As Long
Const conPropNotFound As Integer = 3270

'First get a new file handle
hfile = FreeFile
Open pPath For Output As hfile

Set dbs = CurrentDb

' Enumerate through QueryDefs collection.
For Each qdf In dbs.QueryDefs
With qdf
Print #hfile, "--------------------"
Print #hfile, "Name: " & .Name
Print #hfile, "Description: " & .Properties("Description")
Print #hfile, "Modified: " & .LastUpdated
Print #hfile, "Created: " & .DateCreated
Select Case .Type
Case dbQAction
Print #hfile, "Type: Action"
Case dbQAppend
Print #hfile, "Type: Append"
Case dbQCompound
Print #hfile, "Type: Compound"
Case dbQCrosstab
Print #hfile, "Type: Crosstab"
Case dbQDDL
Print #hfile, "Type: DDL"
Case dbQDelete
Print #hfile, "Type: Delete"
Case dbQMakeTable
Print #hfile, "Type: MakeTable"
Case dbQProcedure
Print #hfile, "Type: Procedure"
Case dbQSelect
Print #hfile, "Type: Select"
Case dbQSetOperation
Print #hfile, "Type: Set Operation"
Case dbQSPTBulk
Print #hfile, "Type: SPT Bulk"
Case dbQSQLPassThrough
Print #hfile, "Type: PassThrough"
Case dbQUpdate
Print #hfile, "Type: Update"

Case Else
Print #hfile, "Type: Unknown"
End Select
Print #hfile, "SQL: " & vbCrLf & vbCrLf & .SQL
For Each param In .Parameters
Print #hfile, "Parameter Name: " & param.Name
Select Case param.Type
Case dbBigInt
Print #hfile, "Parameter Type: Big Integer"
Case dbBinary
Print #hfile, "Parameter Type: Binary"
Case dbBoolean
Print #hfile, "Parameter Type: Boolean"
Case dbByte
Print #hfile, "Parameter Type: Byte"
Case dbChar
Print #hfile, "Parameter Type: Char"
Case dbCurrency
Print #hfile, "Parameter Type: Currency"
Case dbDate
Print #hfile, "Parameter Type: Date/Time"
Case dbDecimal
Print #hfile, "Parameter Type: Decimal"
Case dbDouble
Print #hfile, "Parameter Type: Double"
Case dbFloat
Print #hfile, "Parameter Type: Float"
Case dbGUID
Print #hfile, "Parameter Type: GUID"
Case dbInteger
Print #hfile, "Parameter Type: Integer"
Case dbLong
Print #hfile, "Parameter Type: Long"
Case dbLongBinary
Print #hfile, "Parameter Type: Long Binary (OLE Object)"
Case dbMemo
Print #hfile, "Parameter Type: Memo"
Case dbNumeric
Print #hfile, "Parameter Type: Numeric"
Case dbSingle
Print #hfile, "Parameter Type: Single"
Case dbText
Print #hfile, "Parameter Type: Text"
Case dbTime
Print #hfile, "Parameter Type: Time"
Case dbTimeStamp
Print #hfile, "Parameter Type: Time Stamp"
Case dbVarBinary
Print #hfile, "Parameter Type: VarBinary"

Case Else
Print #hfile, "Parameter Type: Unknown"
End Select
Next param
Print #hfile, "Updateable: " & .Updatable
Print #hfile, "Connect: " & .Connect
Print #hfile, "Returns Records: " & .ReturnsRecords

End With
NewQ: Next qdf

Close hfile
fListQueries = True

Exit_fListQueries:
Set qdf = Nothing
Set dbs = Nothing
Reset
Exit Function

Err_fListQueries:
If Err = conPropNotFound Then
Print #hfile, "Description:"
Resume Next
Else
If Err = 3078 Or Err = 91 Then
Print #hfile, "**This query has problems: " & vbCrLf & Err.Description
Resume NewQ
Else
fListQueries = False
MsgBox "Error Number: " & Err.Number & " " & Err.Description
Resume Exit_fListQueries
End If
End If
End Function
'***end code***
 

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