|
Private Sub 保存_Click()
On Error GoTo Err_保存_Click
'定义保存“查询语句”的字符型变量
Dim STemp As String
'判断“工号”组合框是否为空
If Me![工号] <> "" Then
'为保存内部调动信息“查询语句”字符变量赋值
STemp = "INSERT INTO 职员内部调动 "
STemp = STemp & "( 工号,姓名,性别,原组织机构,新组织机构,"
STemp = STemp & "调动日期,调动原因,备注 )"
STemp = STemp & "VALUES ( '" & Me![工号] & "','" & Me![姓名] & "',"
STemp = STemp & "'" & Me![性别] & "','" & Me![原组织机构] & "',"
STemp = STemp & "'" & Me![新组织机构] & "','" & Me![调动日期] & "',"
STemp = STemp & "'" & Me![调动原因] & "','" & Me![备注] & "')"
'使用DoCmd对象的RunSQL方法执行查询
DoCmd.RunSQL STemp
'为更新职员基本信息“查询语句”字符变量赋值
STemp = " update 职员基本资料 "
STemp = STemp & "SET 组织机构= ''' & Me![新组织机构] & ''' "
STemp = STemp & "WHERE 工号=" & Me![工号] & ""
'使用DoCmd对象的RunSQL方法执行查询
DoCmd.RunSQL STemp
Else
'如果“工号”为空,则弹出”警告“信息
MsgBox "“工号”不能为空,请重新输入!", vbOKOnly, "警告"
'把光标置于“工号”组合框内
Me![工号].SetFocus
End If
'刷新“职员内部调动 子窗体”
Me![职员内部调动 子窗体].Requery
Exit_保存_Click:
Exit Sub
Err_保存_Click:
MsgBox Err.Description
Resume Exit_保存_Click
End Sub |
|