?? frmmain.frm
字號(hào):
'循環(huán)字段信息
For Each oField In rsAccess.Fields
Printer.CurrentX = 1000
j = Printer.CurrentY
Printer.Print oField.Name
Printer.CurrentX = 3000
If Printer.CurrentY < j Then
j = Printer.CurrentY
End If
Printer.CurrentY = j
'獲取數(shù)據(jù)類型
Printer.Print GetFieldType(oField.Type)
Printer.CurrentX = 5000
If Printer.CurrentY < j Then
j = Printer.CurrentY
End If
Printer.CurrentY = j
Printer.Print oField.Size
Printer.CurrentX = 7000
If Printer.CurrentY < j Then
j = Printer.CurrentY
End If
Printer.CurrentY = j
Printer.Print oField.Required
Printer.CurrentX = 9000
If Printer.CurrentY < j Then
j = Printer.CurrentY
End If
Printer.CurrentY = j
Printer.Print oField.AllowZeroLength
i = i + 1
Next
End If
'獲取索引
If oTable.Indexes.Count > 0 Then
Printer.Print ""
Printer.CurrentX = 500
Printer.FontBold = True
Printer.Print "索引列表"
Printer.FontBold = False
j = Printer.CurrentY
Printer.CurrentX = 1000
Printer.Print "索引名稱"
If Printer.CurrentY < j Then
j = Printer.CurrentY
End If
Printer.CurrentY = j
Printer.CurrentX = 3000
Printer.Print "字段"
If Printer.CurrentY < j Then
End If
Printer.CurrentY = j
Printer.CurrentX = 6000
Printer.Print "唯一"
j = Printer.CurrentY
Printer.CurrentX = 1000
Printer.Print "----------------"
If Printer.CurrentY < j Then
j = Printer.CurrentY
End If
Printer.CurrentY = j
Printer.CurrentX = 3000
Printer.Print "----------"
If Printer.CurrentY < j Then
j = Printer.CurrentY
End If
Printer.CurrentY = j
Printer.CurrentX = 6000
Printer.Print "----------"
'循環(huán)表索引結(jié)構(gòu)
For i = 0 To oTable.Indexes.Count - 1
j = Printer.CurrentY
Printer.CurrentX = 1000
Printer.Print oTable.Indexes(i).Name
If Printer.CurrentY < j Then
j = Printer.CurrentY
End If
Printer.CurrentY = j
Printer.CurrentX = 3000
Printer.Print oTable.Indexes(i).Fields
If Printer.CurrentY < j Then
j = Printer.CurrentY
End If
Printer.CurrentY = j
Printer.CurrentX = 6000
Printer.Print oTable.Indexes(i).Unique
Next i
End If
'釋放,進(jìn)行下一個(gè)表
Set rsAccess = Nothing
'是否每個(gè)表輸出為一頁
If chkSeparated.Value = vbChecked Then
Printer.EndDoc
Else
Printer.Print ""
Printer.Print ""
End If
End If
Next
If Not chkSeparated.Value = vbChecked Then
Printer.EndDoc
End If
'釋放數(shù)據(jù)庫變量
Set dbAccess = Nothing
MsgBox "當(dāng)前Access數(shù)據(jù)庫結(jié)構(gòu)已經(jīng)打印到 " & Printer.DeviceName, vbInformation, "完畢"
Screen.MousePointer = vbDefault
Exit Sub
End If
NoDB:
If Err.Number = 3031 Then '數(shù)據(jù)庫需要密碼
frmPassword.Show vbModal
If frmPassword.pblnCancel = True Then Exit Sub
cmdPrint_Click
Err.Clear
Exit Sub
End If
MsgBox Err.Description
Screen.MousePointer = vbDefault
End Sub
'獲取字段類型函數(shù)
Private Function GetFieldType(TypeCode As Integer)
Select Case TypeCode
Case dbBinary
GetFieldType = "Binary"
Case dbBoolean
GetFieldType = "Boolean"
Case dbByte
GetFieldType = "Byte"
Case dbChar
GetFieldType = "Character"
Case dbCurrency
GetFieldType = "Currency"
Case dbDate
GetFieldType = "Date/Time"
Case dbDecimal
GetFieldType = "Decimal"
Case dbDouble
GetFieldType = "Double"
Case dbFloat
GetFieldType = "Float"
Case dbGUID
GetFieldType = "GUID"
Case dbInteger
GetFieldType = "Integer"
Case dbLong
GetFieldType = "Long"
Case dbLongBinary
GetFieldType = "OLE Object"
Case dbMemo
GetFieldType = "Memo"
Case dbNumeric
GetFieldType = "Numeric"
Case dbSingle
GetFieldType = "Single"
Case dbText
GetFieldType = "Text"
Case dbTime
GetFieldType = "Time"
Case dbTimeStamp
GetFieldType = "TimeStamp"
Case dbVarBinary
GetFieldType = "VarBinary"
Case Else
GetFieldType = "Undetermined"
End Select
End Function
'輸出結(jié)構(gòu)到HTML文件過程
Private Sub PrintHTML()
Dim SaveFile As String
On Error GoTo CancelHTML
'對(duì)話框
With dlgCommon
.CancelError = True
.DialogTitle = "保存 HTML 頁面..."
.Filter = "網(wǎng)頁文件 *.htm|*.htm;*.html"
.InitDir = "C:\"
.FileName = "Structure.htm"
.ShowSave
SaveFile = .FileName
End With
DoEvents
Open SaveFile For Output As #2
Set dbAccess = OpenDatabase(Trim(txtDBPath), True, True)
'HTML 文件模板
Print #2, "<html>"
Print #2, "<head>"
Print #2, "<meta name='Access Structure Print' content=Joseph Surls'>"
Print #2, "<title>" & "Access 數(shù)據(jù)庫結(jié)構(gòu),當(dāng)前數(shù)據(jù)庫是:" & Trim(txtDBPath) & "</title>"
Print #2, "</head>"
Print #2, "<body bgcolor='#0099FF'>"
Print #2, "<p><font size='1'>"
Print #2, "數(shù)據(jù)庫路徑:" & Trim(txtDBPath)
Print #2, "</a></font></p>"
For Each oTable In dbAccess.TableDefs
Print #2, "<p><b><u><font size='4' color='#000000'>"
Print #2, "表名稱: " & oTable.Name & "</font><br>"
Print #2, "</u></b><font size='2'>"
Print #2, "建立日期 - " & oTable.DateCreated & "<br>"
Print #2, "最終修改 - " & oTable.LastUpdated & "<br>"
Print #2, "總記錄數(shù) - " & oTable.RecordCount & "<br>"
Print #2, "-----------------------------------------------------------"
Print #2, "</font></p>"
'無系統(tǒng)表
If Not UCase(Left(oTable.Name, 4)) = "MSYS" Then
'打開表記錄
Set rsAccess = dbAccess.OpenRecordset(oTable.Name, dbOpenTable)
Print #2, "<p> <font size='2'> </font><b><font size='3'>字段列表</font></b></p>"
Print #2, "<table border='0' width='100%'>"
Print #2, "<tr><td width='10%' align='center'></td>"
Print #2, "<td width='30%' align='center'>"
Print #2, "<p align='center'><u>字段名稱</u></td>"
Print #2, "<td width='20%' align='center'><u>類型</u></td>"
Print #2, "<td width='10%' align='center'><u>寬度</u></td>"
Print #2, "<td width='10%' align='center'><u>需求</u></td>"
Print #2, "<td width='44%' align='center'><u>允許空值</u></td>"
Print #2, "<td width='16%' align='center'></td></tr>"
'循環(huán)表字段
For Each oField In rsAccess.Fields
Print #2, "<tr><td width='10%' align='center'></td>"
Print #2, "<td width='30%' align='center'>"
Print #2, oField.Name & "</td>"
Print #2, "<td width='20%' align='center'>"
'獲取字段類型
Print #2, GetFieldType(oField.Type) & "</td>"
Print #2, "<td width='10%' align='center'>"
Print #2, oField.Size & "</td>"
Print #2, "<td width='10%' align='center'>"
Print #2, oField.Required & "</td>"
Print #2, "<td width='44%' align='center'>"
Print #2, oField.AllowZeroLength & "</td>"
Print #2, "<td width='16%' align='center'></td>"
Print #2, "</tr>"
Next
Print #2, "</table>"
'索引
If oTable.Indexes.Count > 0 Then
Print #2, "<p> <b>索引列表</b></p>"
Print #2, "<table border='0' width='100%'>"
Print #2, "<tr>"
Print #2, "<td width='7%' align='center'></td>"
Print #2, "<td width='23%' align='center'><u>索引名稱</u></td>"
Print #2, "<td width='44%' align='center'><u>字段</u></td>"
Print #2, "<td width='19%' align='center'><u>唯一</u></td>"
Print #2, "<td width='7%' align='center'></td>"
Print #2, "</tr>"
For i = 0 To oTable.Indexes.Count - 1
Print #2, "<tr>"
Print #2, "<td width='7%' align='center'></td>"
Print #2, "<td width='23%' align='center'>"
Print #2, oTable.Indexes(i).Name & "</td>"
Print #2, "<td width='44%' align='center'>"
Print #2, oTable.Indexes(i).Fields & "</td>"
Print #2, "<td width='19%' align='center'>"
Print #2, oTable.Indexes(i).Unique & "</td>"
Print #2, "<td width='7%' align='center'></td>"
Print #2, "</tr>"
Next i
End If
Print #2, "</table>"
Print #2, "<p>=======================================================================================================================</p>"
End If
Next
Print #2, "<p align='center'>列表結(jié)束<br>"
Print #2, "本頁面使用Access數(shù)據(jù)庫結(jié)構(gòu)打印工具建立,建立日期: - " & _
Date & "</p>"
Print #2, "</body>"
Print #2, "</html>"
Close #2
MsgBox "恭喜,您的文件已經(jīng)保存為 " & dlgCommon.FileName, vbInformation, "完畢"
Exit Sub
CancelHTML:
If Err.Number = 32755 Then
Exit Sub
Else
MsgBox Err.Number & Chr(10) & _
Err.Description
End If
End Sub
Private Sub optHTML_Click()
chkSeparated.Enabled = False
chkSystemTables.Enabled = False
End Sub
Private Sub optPrinter_Click()
chkSeparated.Enabled = True
chkSystemTables.Enabled = True
End Sub
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -