📄 addsform.frm
字号:
VERSION 5.00
Begin VB.Form AddSForm
Caption = "添加特殊项"
ClientHeight = 4590
ClientLeft = 6915
ClientTop = 4455
ClientWidth = 3915
Icon = "AddSForm.frx":0000
LinkTopic = "Form1"
ScaleHeight = 4590
ScaleWidth = 3915
Begin VB.ComboBox cmbID
Height = 315
Left = 1200
TabIndex = 11
Text = "Combo2"
Top = 120
Visible = 0 'False
Width = 2415
End
Begin VB.ComboBox cmbName
Height = 315
Left = 1350
TabIndex = 9
Text = "Combo1"
Top = 510
Width = 2415
End
Begin VB.CommandButton cmdCancel
Caption = "取消"
Height = 375
Left = 1920
TabIndex = 7
Top = 3720
Width = 1095
End
Begin VB.CommandButton cmdAdd
Caption = "添加"
Height = 375
Left = 360
TabIndex = 6
Top = 3720
Width = 1095
End
Begin VB.TextBox txtValue
Height = 375
Index = 4
Left = 1350
TabIndex = 5
Top = 2715
Width = 2415
End
Begin VB.TextBox txtValue
Height = 375
Index = 3
Left = 1350
TabIndex = 3
Top = 2010
Width = 2415
End
Begin VB.TextBox txtValue
Height = 375
Index = 2
Left = 1350
TabIndex = 1
Top = 1305
Width = 2415
End
Begin VB.Label Label2
Caption = "职工ID"
Height = 375
Left = 0
TabIndex = 10
Top = 120
Visible = 0 'False
Width = 855
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "职工姓名"
Height = 195
Left = 150
TabIndex = 8
Top = 630
Width = 720
End
Begin VB.Label lblField
AutoSize = -1 'True
Caption = "lblField"
Height = 195
Index = 4
Left = 150
TabIndex = 4
Top = 2745
Width = 480
End
Begin VB.Label lblField
AutoSize = -1 'True
Caption = "lblField"
Height = 195
Index = 3
Left = 150
TabIndex = 2
Top = 2070
Width = 480
End
Begin VB.Label lblField
AutoSize = -1 'True
Caption = "lblField"
Height = 195
Index = 2
Left = 150
TabIndex = 0
Top = 1395
Width = 480
End
End
Attribute VB_Name = "AddSForm"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'保证姓名与ID一致
Private Sub cmbName_Click()
cmbID.Text = cmbID.List(cmbName.ListIndex)
End Sub
'添加
Private Sub cmdAdd_Click()
'打开错误处理陷阱
Dim intErrFileNo As Integer '自由文件号
On Error GoTo ErrGoto
'----------------------------------------------------
'生成SQL语句
SQL = "INSERT INTO 特殊项(职工ID,特殊项名称,特殊项金额,特殊项日期) VALUES("""
SQL = SQL & cmbID.Text & ""","""
SQL = SQL & txtValue(2).Text & ""","
SQL = SQL & txtValue(3).Text & ",#"
SQL = SQL & txtValue(4).Text & "#)"
'打开数据连接
OpenDBFile
'执行SQL
gCon.Execute SQL
'关闭数据连接
CloseDBFile
Me.Hide
'刷新数据
SpecialForm.Adodc1.Refresh
'----------------------------------------------------
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) + "Command1_Click(AddEForm)" + Chr(34), Chr(34) + App.Title + Chr(34)
MsgBox Err.Description
Close #intErrFileNo
Me.Hide
End Sub
'退出
Private Sub cmdCancel_Click()
Me.Hide
End Sub
'初始化
Private Sub Form_activate()
'打开错误处理陷阱
Dim intErrFileNo As Integer '自由文件号
On Error GoTo ErrGoto
'----------------------------------------------------
lblField(2).Caption = "特殊项名称"
lblField(3).Caption = "特殊项金额"
lblField(4).Caption = "特殊项日期"
For i = 2 To 4
txtValue(i) = ""
Next
cmbID.Clear
cmbName.Clear
'打开数据集
OpenRS "Select 职工ID,姓名 from 职工"
'添加到ComboBox中
While Not gRst.EOF
cmbID.AddItem gRst("职工ID")
cmbName.AddItem gRst("姓名")
gRst.MoveNext
Wend
'关闭数据集
CloseRS
'----------------------------------------------------
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) + "Form_Load(AddSForm)" + Chr(34), Chr(34) + App.Title + Chr(34)
Close #intErrFileNo
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -