?? jishuziliao.dob
字號:
EndProperty
_Version = 393216
End
Begin MSAdodcLib.Adodc Adodc2
Height = 330
Left = 4440
Top = 0
Visible = 0 'False
Width = 1890
_ExtentX = 3334
_ExtentY = 582
ConnectMode = 0
CursorLocation = 3
IsolationLevel = -1
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 3
LockType = 3
CommandType = 1
CursorOptions = 0
CacheSize = 50
MaxRecords = 0
BOFAction = 0
EOFAction = 0
ConnectStringType= 1
Appearance = 1
BackColor = -2147483643
ForeColor = -2147483640
Orientation = 0
Enabled = -1
Connect = ""
OLEDBString = ""
OLEDBFile = ""
DataSourceName = ""
OtherAttributes = ""
UserName = ""
Password = ""
RecordSource = ""
Caption = "Adodc2"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋體"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
_Version = 393216
End
End
Attribute VB_Name = "JiShuZiLiao"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
Private Sub cmdAdd_Click()
On Error GoTo AddErr
datPrimaryRS.Recordset.AddNew
DTPicker1(0).Value = Format(Now(), "Short Date")
DTPicker1(1).Value = Format(Now(), "Short Date")
Exit Sub
AddErr:
MsgBox Err.Description
End Sub
Private Sub cmdAll_Click()
datPrimaryRS.Recordset.Filter = ""
datPrimaryRS.Refresh
Adodc2.Recordset.Filter = ""
Adodc2.Refresh
SSTab1.Tab = 1
End Sub
Private Sub cmdCancel_Click()
SSTab1.Tab = 1
End Sub
Private Sub cmdDelete_Click()
On Error GoTo DeleteErr
Dim nYN As Byte
nYN = MsgBox("您正準備刪除當前記錄。" & Chr(13) & Chr(13) & _
"假如您單擊“是”,您將不能撤消這個刪除操作。" & Chr(13) & _
"您確認刪除這條記錄嗎?", vbExclamation + vbYesNo)
If nYN = vbYes Then
With datPrimaryRS.Recordset
If .EOF And .BOF Then Exit Sub
.Delete
.MoveNext
If .RecordCount > 0 And .EOF Then
.MoveLast
ElseIf .RecordCount = 0 Then .MovePrevious
End If
End With
End If
Exit Sub
DeleteErr:
MsgBox Err.Description
End Sub
Private Sub cmdFilter_Click()
Dim strFilter As String
Dim strFilter2 As String
'生成filter字符串
strFilter = ""
If Trim(txtFields(14).Text) <> "" Then
strFilter = "總號=" & Trim(txtFields(14).Text)
End If
If Not IsNull(DTPicker1(2).Value) Then
If strFilter = "" Then
strFilter = "編制日期 >= #" & Format(DTPicker1(2).Value, "yyyy-mm-dd") & "#"
Else
strFilter = strFilter & " and 編制日期 >= #" & Format(DTPicker1(2).Value, "yyyy-mm-dd") & "#"
End If
End If
If Not IsNull(DTPicker1(3).Value) Then
If strFilter = "" Then
strFilter = "編制日期 <= #" & Format(DTPicker1(3).Value, "yyyy-mm-dd") & "#"
Else
strFilter = strFilter & " and 編制日期 <= #" & Format(DTPicker1(3).Value, "yyyy-mm-dd") & "#"
End If
End If
If txtFields(15).Text <> "" Then
If strFilter = "" Then
strFilter = "資料名稱 like '%" & txtFields(15).Text & "%'"
Else
strFilter = strFilter & " and 資料名稱 like '%" & txtFields(15).Text & "%'"
End If
End If
If DataCombo3.Text <> "" Then
If strFilter = "" Then
strFilter = "分類ID=" & DataCombo3.BoundText
strFilter2 = "分類='" & DataCombo3.Text & "'"
Else
strFilter = strFilter & " and 分類ID=" & DataCombo3.BoundText
strFilter2 = strFilter & " and 分類='" & DataCombo3.Text & "'"
End If
End If
datPrimaryRS.Recordset.Filter = "" 'adFilterNone
datPrimaryRS.Recordset.Filter = strFilter
Adodc2.Recordset.Filter = "" 'adFilterNone
Adodc2.Recordset.Filter = strFilter2
SSTab1.Tab = 1
End Sub
Private Sub cmdPrint_Click()
Dim oExcel As Object
Dim oBook As Object
Dim oSheet As Object
Dim DataArray() As Variant
Dim i, j, Num As Integer
Screen.MousePointer = vbHourglass
'Start a new workbook in Excel
Set oExcel = CreateObject("Excel.Application")
Set oBook = oExcel.Workbooks.Add
'Create an array
Num = Adodc2.Recordset.RecordCount
If Num = 0 Then
MsgBox "發排數據為空。", vbInformation
Exit Sub
End If
ReDim DataArray(1 To Num, 1 To 13) As Variant
Adodc2.Recordset.MoveFirst
For i = 1 To Num
For j = 1 To 13
DataArray(i, j) = Adodc2.Recordset.Fields(j - 1).Value
Next
Adodc2.Recordset.MoveNext
Next
Adodc2.Recordset.MoveFirst
'Add headers to the worksheet on row 1
Set oSheet = oBook.Worksheets(1)
oSheet.Range("A1:M1").Select
With oExcel.Selection
.HorizontalAlignment = -4108
.VerticalAlignment = -4108
.WrapText = False
.Orientation = 0
.AddIndent = False
.ShrinkToFit = False
.MergeCells = True
End With
oSheet.Range("A1").Value = "技術資料登記帳"
oSheet.Range("A2").Value = " 年 月 日"
oSheet.Range("B2").Value = "總號"
oSheet.Range("C2").Value = "分類"
oSheet.Range("D2").Value = "文別"
oSheet.Range("E2").Value = "密別"
oSheet.Range("F2").Value = "資料名稱"
oSheet.Range("G2").Value = "編制單位"
oSheet.Range("H2").Value = "編制日期"
oSheet.Range("I2").Value = "來源"
oSheet.Range("J2").Value = "份數"
oSheet.Range("K2").Value = "頁數"
oSheet.Range("L2").Value = "單價"
oSheet.Range("M2").Value = "備注"
oSheet.Range("A2:M2").Select
With oExcel.Selection
.HorizontalAlignment = -4108
.VerticalAlignment = -4108
.WrapText = False
.Orientation = 0
.AddIndent = False
.ShrinkToFit = False
End With
'Transfer the array to the worksheet starting at cell A2
oSheet.Range("A3").Resize(Num, 13).Value = DataArray
oSheet.Range("A2:M" & CStr(Num + 2)).Select
oExcel.Selection.Borders(5).LineStyle = -4142
oExcel.Selection.Borders(6).LineStyle = -4142
With oExcel.Selection.Borders(7)
.LineStyle = 1
.Weight = 3
.ColorIndex = -4105
End With
With oExcel.Selection.Borders(8)
.LineStyle = 1
.Weight = 3
.ColorIndex = -4105
End With
With oExcel.Selection.Borders(9)
.LineStyle = 1
.Weight = 3
.ColorIndex = -4105
End With
With oExcel.Selection.Borders(10)
.LineStyle = 1
.Weight = 3
.ColorIndex = -4105
End With
With oExcel.Selection.Borders(11)
.LineStyle = 1
.Weight = 2
.ColorIndex = -4105
End With
With oExcel.Selection.Borders(12)
.LineStyle = 1
.Weight = 2
.ColorIndex = -4105
End With
' oSheet.Range("E" & CStr(Num + 3)).Value = "合計"
' oSheet.Range("F" & CStr(Num + 3)).Formula = "=SUM(F3:F" & CStr(Num + 2) & ")"
' oSheet.Range("G" & CStr(Num + 3)).Formula = "=SUM(G3:G" & CStr(Num + 2) & ")"
oSheet.Columns("A:A").EntireColumn.AutoFit
oSheet.Columns("B:B").EntireColumn.AutoFit
oSheet.Columns("C:C").EntireColumn.AutoFit
oSheet.Columns("D:D").EntireColumn.AutoFit
oSheet.Columns("E:E").EntireColumn.AutoFit
oSheet.Columns("F:F").EntireColumn.AutoFit
oSheet.Columns("G:G").EntireColumn.AutoFit
oSheet.Columns("H:H").EntireColumn.AutoFit
oSheet.Columns("I:I").EntireColumn.AutoFit
oSheet.Columns("J:J").EntireColumn.AutoFit
oSheet.Columns("K:K").EntireColumn.AutoFit
oSheet.Columns("L:L").EntireColumn.AutoFit
oSheet.Columns("M:M").EntireColumn.AutoFit
With oSheet.PageSetup
.PrintTitleRows = ""
.PrintTitleColumns = ""
End With
oSheet.PageSetup.PrintArea = ""
With oSheet.PageSetup
.LeftHeader = ""
.CenterHeader = ""
.RightHeader = ""
.LeftFooter = ""
.CenterFooter = ""
.RightFooter = ""
.LeftMargin = oExcel.InchesToPoints(0.75)
.RightMargin = oExcel.InchesToPoints(0.75)
.TopMargin = oExcel.InchesToPoints(1)
.BottomMargin = oExcel.InchesToPoints(1)
.HeaderMargin = oExcel.InchesToPoints(0.5)
.FooterMargin = oExcel.InchesToPoints(0.5)
.PrintHeadings = False
.PrintGridlines = False
.PrintComments = -4142
.CenterHorizontally = False
.CenterVertically = False
.Orientation = 2
.Draft = False
.PaperSize = 12
.FirstPageNumber = -4105
.Order = 1
.BlackAndWhite = False
.Zoom = 100
End With
oSheet.Range("A1").Select
oExcel.Visible = True
Screen.MousePointer = vbDefault
Set oExcel = Nothing
Set oBook = Nothing
Set oSheet = Nothing
End Sub
Private Sub cmdRefresh_Click()
'只有多用戶應用程序需要
On Error GoTo RefreshErr
datPrimaryRS.Refresh
Exit Sub
RefreshErr:
MsgBox Err.Description
End Sub
Private Sub cmdUpdate_Click()
On Error GoTo UpdateErr
datPrimaryRS.Recordset.UpdateBatch adAffectAll
Exit Sub
UpdateErr:
MsgBox Err.Description
End Sub
Private Sub datPrimaryRS_MoveComplete(ByVal adReason As ADODB.EventReasonEnum, ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)
datPrimaryRS.Caption = CStr(datPrimaryRS.Recordset.AbsolutePosition)
lbl記錄數.Caption = CStr(datPrimaryRS.Recordset.RecordCount)
End Sub
Private Sub SSTab1_Click(PreviousTab As Integer)
Select Case SSTab1.Tab
Case 0
If Not (Adodc2.Recordset.EOF Or Adodc2.Recordset.BOF) Then
datPrimaryRS.Recordset.MoveFirst
datPrimaryRS.Recordset.Find "總號 = " & Adodc2.Recordset.Fields("總號").Value, , adSearchForward, 0
End If
Case 1
If PreviousTab = 0 Then
Adodc2.Refresh
If Not (datPrimaryRS.Recordset.EOF Or datPrimaryRS.Recordset.BOF) Then
Adodc2.Recordset.MoveFirst
Adodc2.Recordset.Find "總號 = " & datPrimaryRS.Recordset.Fields("總號").Value, , adSearchForward, 0
End If
End If
End Select
End Sub
Private Sub UserDocument_Initialize()
With datPrimaryRS
.ConnectionString = pConn
.RecordSource = "select 總號,登記日期,分類id,文別,密別,資料名稱,編制單位,編制日期,來源,份數,頁數,單價,備注 from 技術資料 Order by 總號"
.Refresh
End With
With Adodc1
.ConnectionString = pConn
.RecordSource = "圖書分類"
.Refresh
End With
With Adodc2
.ConnectionString = pConn
.RecordSource = "SELECT 技術資料.登記日期, 技術資料.總號, 圖書分類.分類, 技術資料.文別, " & _
"技術資料.密別, 技術資料.資料名稱, 技術資料.編制單位, " & _
"技術資料.編制日期, 技術資料.來源, 技術資料.份數, 技術資料.頁數, " & _
"技術資料.單價, 技術資料.備注 " & _
"FROM 技術資料 LEFT OUTER JOIN " & _
"圖書分類 ON 技術資料.分類id = 圖書分類.分類ID"
.Refresh
End With
End Sub
Private Sub UserDocument_Show()
datPrimaryRS.Refresh
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -