?? 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 + -