📄 form4.frm
字号:
VERSION 5.00
Begin VB.Form report1
BorderStyle = 1 'Fixed Single
Caption = "人事卡片报表"
ClientHeight = 1830
ClientLeft = 45
ClientTop = 330
ClientWidth = 5010
ControlBox = 0 'False
LinkTopic = "Form4"
LockControls = -1 'True
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 1830
ScaleWidth = 5010
StartUpPosition = 2 'CenterScreen
Begin VB.OptionButton Option2
Caption = "自定义类型"
Height = 495
Left = 720
TabIndex = 4
Top = 840
Width = 1455
End
Begin VB.OptionButton Option1
Caption = "Excel类型"
Height = 495
Left = 720
TabIndex = 3
Top = 480
Value = -1 'True
Width = 1215
End
Begin VB.Frame Frame1
Caption = "报表类型"
Height = 1215
Left = 360
TabIndex = 2
Top = 240
Width = 2535
End
Begin VB.CommandButton Command2
Caption = "关闭"
Height = 495
Left = 3240
TabIndex = 1
Top = 960
Width = 1455
End
Begin VB.CommandButton Command1
Caption = "打开报表"
Height = 495
Left = 3240
TabIndex = 0
Top = 360
Width = 1455
End
End
Attribute VB_Name = "report1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim exlapp As New Excel.Application
Dim exlbook As Excel.Workbook
Dim exlsheet As Excel.Worksheet
Dim rspcl As ADODB.Recordset
'Dim model As Boolean
Private Sub Command1_Click()
If Option1.Value = True Then
Dim rows As Integer
rows = 2
If rspcl.RecordCount > 0 Then
While Not rspcl.EOF
With exlapp.Sheets(1)
For i = 0 To 16
.Cells(rows, i + 1) = rspcl.Fields(i)
Next i
rspcl.MoveNext
rows = rows + 1
End With
Wend
exlapp.Visible = True
Else
MsgBox "database error!"
End If
End If
If Option2.Value = True Then
drp1.Visible = True
End If
End Sub
Private Sub Command2_Click()
Unload Me
frmmain.Visible = True
End Sub
Private Sub Form_Load()
Set exlapp = New Excel.Application
exlapp.Workbooks.Open "e:\man\pcl.xlt"
Set rspcl = New ADODB.Recordset
rspcl.Open "select * from pcl", cn, adOpenStatic, adLockOptimistic
End Sub
Private Sub Form_Unload(Cancel As Integer)
rspcl.Close
Set rspcl = Nothing
exlapp.quit
End Sub
Private Sub Option1_GotFocus()
Option1.Value = True
End Sub
Private Sub Option2_GotFocus()
Option2.Value = True
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -