📄 frmmain.frm
字号:
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Begin VB.Form frmMain
BorderStyle = 1 'Fixed Single
Caption = "Access 数据库结构打印工具 Ver 1.0"
ClientHeight = 3465
ClientLeft = 2565
ClientTop = 2565
ClientWidth = 5190
Icon = "frmMain.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
Picture = "frmMain.frx":030A
ScaleHeight = 3465
ScaleWidth = 5190
StartUpPosition = 2 '屏幕中心
Begin VB.Frame Frame1
Height = 975
Left = 90
TabIndex = 6
Top = 1560
Width = 5010
Begin VB.CheckBox chkSeparated
Caption = "每个表分为一页"
Height = 195
Left = 225
TabIndex = 10
Top = 240
Value = 1 'Checked
Width = 2715
End
Begin VB.CheckBox chkSystemTables
Caption = "包括系统表"
Height = 195
Left = 225
TabIndex = 9
Top = 600
Width = 2055
End
Begin VB.OptionButton optHTML
Caption = "输出到HTML"
Height = 195
Left = 3045
TabIndex = 8
Top = 600
Width = 1665
End
Begin VB.OptionButton optPrinter
Caption = "输出到打印机"
Height = 195
Left = 3045
TabIndex = 7
Top = 240
Value = -1 'True
Width = 1470
End
End
Begin VB.CommandButton cmdPrint
Caption = "打印"
Height = 615
Left = 1688
TabIndex = 5
Top = 2760
Width = 1815
End
Begin MSComDlg.CommonDialog dlgCommon
Left = 825
Top = 2775
_ExtentX = 847
_ExtentY = 847
_Version = 393216
CancelError = -1 'True
DialogTitle = "Select Access Database"
Filter = "Access Databases *.mdb |*.mdb"
InitDir = "C:\"
End
Begin VB.TextBox txtDBPath
ForeColor = &H000000FF&
Height = 345
Left = 128
TabIndex = 1
Top = 960
Width = 3870
End
Begin VB.CommandButton cmdBrowse
Caption = "浏览..."
Height = 345
Left = 4028
TabIndex = 0
Top = 960
Width = 1035
End
Begin VB.Line Line1
X1 = 0
X2 = 4950
Y1 = 840
Y2 = 840
End
Begin VB.Label Label1
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "3 - 单击打印"
BeginProperty Font
Name = "MS Sans Serif"
Size = 9.75
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 240
Index = 2
Left = 885
TabIndex = 4
Top = 600
Width = 1050
End
Begin VB.Label Label1
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "2 - 设置您的打印选项"
BeginProperty Font
Name = "MS Sans Serif"
Size = 9.75
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 240
Index = 1
Left = 885
TabIndex = 3
Top = 360
Width = 1770
End
Begin VB.Label Label1
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "1 - 选择您的 Access 数据库"
BeginProperty Font
Name = "MS Sans Serif"
Size = 9.75
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 240
Index = 0
Left = 885
TabIndex = 2
Top = 120
Width = 2475
End
End
Attribute VB_Name = "frmMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
'数据库对象
Dim dbAccess As DAO.Database
'记录对象
Dim rsAccess As DAO.Recordset
Dim i As Integer
Dim j As Long
'表对象
Dim oTable As DAO.TableDef
'字段对象
Dim oField As DAO.Field
Private Sub cmdBrowse_Click()
On Error GoTo CancelBrowse
'选择数据库对话框
With dlgCommon
.CancelError = True
.InitDir = App.Path
.DialogTitle = "选择数据库..."
.Filter = "Access 数据库 *.mdb|*.mdb"
.FileName = ""
.ShowOpen
txtDBPath = .FileName
End With
Exit Sub
CancelBrowse:
If Err.Number = 32755 Then '用户取消
Exit Sub
Else
MsgBox Err.Number & Chr(10) & _
Err.Description
End If
End Sub
Private Sub cmdPrint_Click()
On Error GoTo NoDB
'如果系统没有安装打印机,则退出
If Printers.Count < 1 Then Exit Sub
'如果没有指定数据库,则退出
If txtDBPath = "" Then Exit Sub
'数据库密码保护
If frmPassword.pstrPassword = "" Then
'没有密码
Set dbAccess = OpenDatabase(Trim(txtDBPath), True, True)
Else
'指定密码
Set dbAccess = OpenDatabase(Trim(txtDBPath), True, True, ";pwd=" & frmPassword.pstrPassword)
frmPassword.pstrPassword = ""
End If
If optHTML.Value = True Then '输出结构到 HTML 文件
PrintHTML
Set dbAccess = Nothing
Exit Sub
Else '输出结构到打印机
Screen.MousePointer = vbHourglass
Printer.Print Trim(txtDBPath)
Printer.Print ""
Printer.Print ""
For Each oTable In dbAccess.TableDefs '循环表结构
If chkSystemTables.Value = vbChecked Or Not UCase(Left(oTable.Name, 4)) = "MSYS" Then
'打印页眉
Printer.FontSize = 14
Printer.FontBold = True
Printer.Print "表名 = " & oTable.Name
Printer.FontSize = 8
Printer.FontBold = False
Printer.Print "======================================="
Printer.Print "建立日期 =" & oTable.DateCreated
Printer.Print "最后修改 = " & oTable.LastUpdated
Printer.Print "记录总数 = " & oTable.RecordCount
Printer.Print "---------------------------------------------------"
Printer.Print ""
Printer.Print ""
'不打印系统表
If Not UCase(Left(oTable.Name, 4)) = "MSYS" Then
'打开当前表记录
Set rsAccess = dbAccess.OpenRecordset(oTable.Name, dbOpenTable)
Printer.CurrentX = 500
Printer.FontBold = True
Printer.Print "字段列表"
Printer.FontBold = False
Printer.CurrentX = 1000
j = Printer.CurrentY
Printer.Print "字段名称"
Printer.CurrentX = 3000
If Printer.CurrentY < j Then
j = Printer.CurrentY
End If
Printer.CurrentY = j
Printer.Print "字段类型"
Printer.CurrentX = 5000
If Printer.CurrentY < j Then
j = Printer.CurrentY
End If
Printer.CurrentY = j
Printer.Print "字段宽度"
Printer.CurrentX = 7000
If Printer.CurrentY < j Then
j = Printer.CurrentY
End If
Printer.CurrentY = j
Printer.Print "Required"
Printer.CurrentX = 9000
If Printer.CurrentY < j Then
j = Printer.CurrentY
End If
Printer.CurrentY = j
Printer.Print "允许空"
Printer.CurrentX = 1000
j = Printer.CurrentY
Printer.Print "-------------------"
Printer.CurrentX = 3000
If Printer.CurrentY < j Then
j = Printer.CurrentY
End If
Printer.CurrentY = j
Printer.Print "--------"
Printer.CurrentX = 5000
If Printer.CurrentY < j Then
j = Printer.CurrentY
End If
Printer.CurrentY = j
Printer.Print "--------"
Printer.CurrentX = 7000
If Printer.CurrentY < j Then
j = Printer.CurrentY
End If
Printer.CurrentY = j
Printer.Print "--------------"
Printer.CurrentX = 9000
If Printer.CurrentY < j Then
j = Printer.CurrentY
End If
Printer.CurrentY = j
Printer.Print "---------------"
i = 0
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -