?? thismonthsumform.frm
字號:
VERSION 5.00
Begin VB.Form ThisMonthSumForm
Caption = "當月工資總表"
ClientHeight = 6720
ClientLeft = 615
ClientTop = 1440
ClientWidth = 12360
LinkTopic = "Form1"
MDIChild = -1 'True
ScaleHeight = 6720
ScaleWidth = 12360
Begin VB.CommandButton cmdCancel
Caption = "取消"
Height = 495
Left = 9840
TabIndex = 3
Top = 1680
Width = 1455
End
Begin VB.CommandButton cmdGenerate
Caption = "生成報表"
Height = 495
Left = 9840
TabIndex = 2
Top = 240
Width = 1455
End
Begin VB.CommandButton cmdPrint
Caption = "打印報表"
Height = 495
Left = 9840
TabIndex = 1
Top = 960
Width = 1455
End
Begin VB.OLE OLE1
Height = 6135
Left = 240
SizeMode = 3 'Zoom
TabIndex = 0
Top = 120
Width = 9135
End
End
Attribute VB_Name = "ThisMonthSumForm"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim mMonth As String
Dim SQL As String, mSheet As Worksheet
Private Sub cmdCancel_Click()
Me.Hide
End Sub
'生成報表
Private Sub cmdGenerate_Click()
'打開錯誤處理陷阱
Dim intErrFileNo As Integer '自由文件號
Dim sheet As Worksheet
On Error GoTo ErrGoto
'----------------------------------------------------
'打開Excel
Set gX = GetObject("", "Excel.Application")
'打開月表
SQL = "SELECT * FROM " & mMonth
OpenRS (SQL)
gRst.MoveFirst
Dim i As Integer
i = 0
gX.Workbooks.Close
gX.Workbooks.Add
gX.Visible = True
Set sheet = gX.ActiveSheet
i = i + 1
'添加信息
sheet.Cells(i, 1) = mMonth
i = i + 1
sheet.Cells(i, 1) = "職工ID"
sheet.Cells(i, 2) = "工資取畢"
sheet.Cells(i, 3) = "工資"
While Not gRst.EOF
i = i + 1
sheet.Cells(i, 1) = gRst("職工ID")
sheet.Cells(i, 2) = IIf(gRst("工資取畢"), "是", "否")
sheet.Cells(i, 3) = gRst("工資")
gRst.MoveNext
Wend
CloseRS
Set mSheet = sheet
'存儲文件
gX.ActiveWorkbook.SaveAs App.Path & "\" & mMonth & "總表.xls"
OLE1.CreateEmbed App.Path & "\" & mMonth & "總表.xls"
'----------------------------------------------------
Exit Sub
'-----------------------------
ErrGoto:
'把錯誤信息保存在文件里
intErrFileNo = FreeFile()
Open "YFSystem.ini" For Append As intErrFileNo
Print #intErrFileNo, Chr(34) + Format(Now, "YYYY-MM-DD HH:MM:SS") + Chr(34), Chr(34) + "信息" + Chr(34), Chr(34) + Err.Description + Chr(34), Chr(34) + "cmdGenerate_Click(ThisMonthSalaryForm)" + Chr(34), Chr(34) + App.Title + Chr(34)
Close #intErrFileNo
End Sub
Private Sub cmdPrint_Click()
mSheet.PrintOut
End Sub
Private Sub Form_Load()
mMonth = Format(Date - 30, "YYYYMM")
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -