Print Design View

  • Thread starter Lost in Microbiology
  • Start date
L

Lost in Microbiology

Hello All,

I need to print the design view including the Description field. I used the
analyzer, but it doesn't seem to include that. I am utilizing a colleague's
database, where field names are not always clear, but the combined with a
description is clear.

Thanks in advance for any help.
 
F

fredg

Hello All,

I need to print the design view including the Description field. I used the
analyzer, but it doesn't seem to include that. I am utilizing a colleague's
database, where field names are not always clear, but the combined with a
description is clear.

Thanks in advance for any help.

Design view of what?
The Description field? or the Description property?
What object? A table, form, query, report, etc.?

Why don't you re-think your question, and re-post it, so that someone
who can't see your computer or read your mind will know what it is you
are talking about. Proof reading before sending it would be helpful as
your statement 'but the combined with a description is clear. ' makes
no sense.
 
M

Maverick

With the information we do have, the only suggestion I have it to use Print
Screen and then paste the result in Word to print it. I don't think that is a
complete answer, but then again, we don't have a complete question. LOL
 
L

Lost in Microbiology

Sorry for not being as lucid as my mind was working.

If possible, I would like to print the 'Design View' of a table. The table
contains Field Names that are not very clear. However the 'Description'
column in Design View has a clear explanation of the field.

Thanks.
 
M

Maverick

Well, then my original suggestion would work. Open the table in design view
and press the Print Screen button on your keyboard. Next, open Word (or any
program that can manage an image) and paste the image. You may need to crop
the image to eliminate all of the other stuff in the image, but this will
definitely make it so you can print what you're looking for.

I don't know how to do this function from within Access. My solution is just
a quick and dirty approach.
 
F

fredg

Sorry for not being as lucid as my mind was working.

If possible, I would like to print the 'Design View' of a table. The table
contains Field Names that are not very clear. However the 'Description'
column in Design View has a clear explanation of the field.

Thanks.

Well, Documenter works for me.
If the table field has a description entered, it shows in the
documenter report.
For example, for the LastName field .....
LastName Text 250
AllowZeroLength: False
Attributes: Variable Length
CollatingOrder: General
ColumnHidden: False
ColumnOrder: Default
ColumnWidth: 1995
DataUpdatable: False
*** Description: The last Name ***
DisplayControl: Text Box
GUID: {guid {EA68C3FB-9D4E-4EC6-803E-FEEBE3827248}}
IMEMode: 0
IMESentenceMode: 3
OrdinalPosition: 3
Required: False
SourceField: LastName
SourceTable: tblBasicData
UnicodeCompression

If nothing is entered in the description property for that field,
nothing shows for Description in the Documenter (not even the property
name 'Description')..
 
J

John Spencer

Try copying the following code into a module and then executing it by
typing fBuildDataDictionary in the VBA immediate window. Watch out for
line wraps introduced by the new group

It should build a table with the needed information.

Option Compare Database
Option Explicit

Public Function fBuildDataDictionary()
' Given table tbl_DbDictionary with
'Fields:ItemID Autonumber; SortOrder Number Long
'TableName Text 64; FieldName Text 64
'PrimaryKey Text 25 ; DataType Text 25;
'FieldSize Text 25; Field Description Text 255
' Fill table with information from the properties of the fields

Dim dbAny As DAO.Database
Dim tblAny As DAO.TableDef
Dim fldAny As DAO.Field
Dim strTableName As String, strTableDescription As String
Dim strSQL As String
Dim rstAny As DAO.Recordset
Dim intOrder As Integer

On Error GoTo fBuildDataDictionary_Err

Set dbAny = CurrentDb()
'Clear tbl_DbDictionary
strSQL = "DELETE * FROM tbl_DbDictionary"
dbAny.Execute strSQL, dbFailOnError

Set rstAny = dbAny.OpenRecordset("tbl_DbDictionary")

For Each tblAny In dbAny.TableDefs
strTableName = tblAny.Name
'grab the table description if available
'strTableDescription = tblAny.Properties("Description")

If InStr(1, strTableName, "Msys", vbTextCompare) = 0 _
And InStr(1, strTableName, "~") = 0 _
And InStr(1, strTableName, "src_") <> 1 _
And InStr(1, strTableName, "zzz") <> 1 _
And strTableName <> "tbl_DbDictionary" _
Then
For Each fldAny In tblAny.Fields
With rstAny
.AddNew
intOrder = intOrder + 1
!SortOrder = intOrder 'fldAny.OrdinalPosition + 1
!TableName = strTableName
!FieldName = fldAny.Name
!DataType = fGetFieldTypeName(fldAny.Type)
If !DataType = "Memo" Then
'Memo fields use a 12-byte pointer
'OLE may also use 12-byte pointers - need to check.
!FieldSize = 12
Else
!FieldSize = fldAny.Size
End If
'=======================================================================
' Add additional data to table
'=======================================================================
If Len(fldAny.DefaultValue) > 0 Then
!DefaultValue = fldAny.DefaultValue
End If

If Len(fldAny.ValidationRule) > 0 Then
!ValidationRule = fldAny.ValidationRule
End If

If Len(fldAny.ValidationText) > 0 Then
!ValidationText = fldAny.ValidationText
End If

If fldAny.Required = True Then
!RequiredField = "Required"
Else
!RequiredField = Null
End If


'=======================================================================
'Autoincrement field is primary key in my databases
If fldAny.Attributes And dbAutoIncrField Then
!PrimaryKey = "True"
End If
.Update
End With
Next fldAny
End If
strTableDescription = vbNullString
Next tblAny

sGetFieldDescriptions
MsgBox "Finished building table - tbl_DbDictionary"
fBuildDataDictionary = True
Exit Function

fBuildDataDictionary_Err:
Select Case Err.Number
Case 3270, 3265
If Err.Number = 3270 Then Debug.Print Err.Number & " " & _
Err.Description
'3265 = item not found in this collection
Resume Next
Case 3078 'No such table
'if table does not exist then build it
strSQL = "Create Table tbl_DbDictionary " & _
" (ItemID Counter Constraint PK_ItemID Primary Key" & _
", SortOrder Long, TableName Text(64)" & _
", FieldName Text(64), DataType Text(25)" & _
", PrimaryKey Text(15)" & _
", FieldSize Text(20), FieldDescription Text(255)" & _
", DefaultValue Text(255), ValidationRule Memo" & _
", ValidationText Text(255), RequiredField Text(10) )"
dbAny.Execute strSQL, dbFailOnError

dbAny.TableDefs.Refresh
Resume Next

Case Else
MsgBox Err.Number & ": " & Err.Description, , _
"ERROR: fBuildDataDictionary"

End Select
End Function

Private Function fGetFieldTypeName(fldAnyType) As String
Dim strAny As String
Select Case fldAnyType
Case dbBigInt
strAny = "Big Integer"
Case dbBinary
strAny = "Binary"
Case dbBoolean
strAny = "Boolean"
Case dbByte
strAny = "Byte"
Case dbChar
strAny = "Char"
Case dbCurrency
strAny = "Number (Currency)"
Case dbDate
strAny = "Date/Time"
Case dbDecimal
strAny = "Decimal"
Case dbDouble
strAny = "Number (Long)"
Case dbFloat
strAny = "Number (Float)"
Case dbGUID
strAny = "GUID"
Case dbInteger
strAny = "Number (Integer)"
Case dbLong
strAny = "Number (Long)"
Case dbLongBinary
strAny = "Long Binary (OLE Object)"
Case dbMemo
strAny = "Memo"
Case dbNumeric
strAny = "Numeric"
Case dbSingle
strAny = "Number (Single)"
Case dbText
strAny = "Text"
Case dbTime
strAny = "Time"
Case dbTimeStamp
strAny = "Time Stamp"
Case dbVarBinary
strAny = "VarBinary"
Case Else
strAny = "Unknown Type"
End Select

fGetFieldTypeName = strAny

End Function

Private Sub sGetFieldDescriptions()
'Loop through all the tables and fields in data table
'Collect the field descriptions
Dim dbAny As DAO.Database
Dim rstDictionary As DAO.Recordset
Dim tblAny As DAO.TableDef
Dim strTable As String, strTablePrior As String, strFieldname As String

On Error GoTo sGetFieldDescriptions_Error

Set dbAny = CurrentDb()
Set rstDictionary = dbAny.OpenRecordset("tbl_DbDictionary")

With rstDictionary
strTablePrior = ""

While Not .EOF
strFieldname = !FieldName
strTable = !TableName


If strTablePrior <> strTable Then
Set tblAny = dbAny.TableDefs(strTable)
End If

.Edit
!FieldDescription = _
tblAny.Fields(strFieldname).Properties("Description")
.Update
strTablePrior = !tblName

.MoveNext

Wend
End With

Exit Sub

sGetFieldDescriptions_Error:
Select Case Err.Number
Case 3270, 3265
Resume Next
Case Else

MsgBox Err.Number & ": " & Err.Description, , _
"sGetFieldDescriptions"
End Select

End Sub

Public Function fGetTableDescription(strTableName As String) As String
Dim dbAny As DAO.Database
Dim strTableDescription As String
On Error GoTo fGetTableDescription_Error

Set dbAny = CurrentDb()
strTableDescription =
dbAny.TableDefs(strTableName).Properties("Description")

fGetTableDescription_Exit:
Set dbAny = Nothing
fGetTableDescription = strTableDescription
Exit Function

fGetTableDescription_Error:
Select Case Err.Number
Case 3270, 3265
strTableDescription = vbNullString
Resume fGetTableDescription_Exit
Case Else
MsgBox Err.Number & ": " & Err.Description, , _
"ERROR: fGetTableDescription"

End Select

End Function

'====================================================
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
'====================================================
 

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