|
If Len(Nz(Me.txtSVsn)) = 0 Then
MsgBoxShow "“受监编号”未填写完整!!", "信息未填写"
Exit Sub
End If
If Len(Nz(Me.cmbDistrict)) = 0 Then '检视“监督区域”的输入数据
MsgBoxShow "请输入“监督区域”!!", "信息未填写"
Exit Sub
End If
If Len(Nz(txtSCompName)) = 0 Then '检视“单位名称”的输入数据
MsgBoxShow "请输入“单位名称”!!", "信息未填写"
Exit Sub
End If
If Len(Nz(txtSTel)) = 0 Then '检视“单位电话”的输入数据
MsgBoxShow "请输入“单位电话”!!", "信息未填写"
Exit Sub
Else
On Error GoTo HandleErrorSTel '处理错误
Dim STel As String
STel = CLng(Me.txtSTel)
End If
If Len(Nz(txtChiefME)) = 0 Then '检视“项目负责人”的输入数据
MsgBoxShow "请输入“项目负责人”!!", "信息未填写"
Exit Sub
End If
If Len(Nz(txtChiefMETel)) = 0 Then '检视“负责人电话”的输入数据
MsgBoxShow "请输入“负责人电话”!!", "信息未填写"
Exit Sub
Else
On Error GoTo HandleErrorChiefMETel
Dim ChiefMETel As String
ChiefMETel = CLng(Me.txtChiefMETel)
End If
'定义数据库连接
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
Dim sqlstr As String '定义sql连接字符串
sqlstr = "select SVNum,SVFollowUp from InfoInvestmentComp where SVNum = '" & Me.txtSVYear & Me.txtSVsn & "'" _
& "and SVFollowUp = '" & Me.txtSVFollowUp & "'"
'检查“受监编号”是否重复
rs.Open sqlstr, CurrentProject.Connection, adOpenDynamic, adLockOptimistic
If rs.EOF = False Then
MsgBoxShow "“受监编号”已分配,请重新输入!!”", "注意!!"
Exit Sub
rs.Close
Set rs = Nothing
Else
rs.Close
'连接数据表
sqlstr = "select SVNum,SVFollowUp,District,ComName,CompAddress,Tel,QGrade,QLicence "
sqlstr = sqlstr + "from InfoSupervisionComp"
rs.Open sqlstr, CurrentProject.Connection, adOpenDynamic, adLockOptimistic
rs.AddNew '添加数据
rs("SVNum") = txtSVYear + txtSVsn '受监编号合而为一
If Len(Nz(Me.txtSVFollowUp)) = 0 Then '后续编号设置默认值
rs("SVFollowUp") = "00"
Else
rs("SVFollowUp") = txtSVFollowUp
End If
rs("District") = Trim(Me.txtSCompName)
rs("ComName") = Trim(Me.txtInvestmentComp)
rs("CompAddress") = Trim(Me.txtSCompAddress)
rs("QGrade") = Trim(Me.txtSQG)
rs("QLicence") = Trim(Me.txtSQLicence)
rs("Tel") = Trim(Me.txtSTel)
rs.Update
End If
MsgBoxShow "数据保存成功!!", "操作完成"
rs.Close '断开连接
sqlstr = "select SVNum,SVFollowUp,District,ChiefME,EngineerLicence,Tel from InfoChiefME" '建立新连接
rs.Open sqlstr, CurrentProject.Connection, adOpenDynamic, adLockOptimistic
rs.AddNew
rs("SVNum") = txtSVYear + txtSVsn
rs("SVFollowUp") = Trim(Me.txtSVFollowUp)
rs("District") = Trim(Me.txtSCompName)
rs("ChiefME") = Trim(Me.txtChiefME)
rs("EngineerLicence") = Trim(Me.txtChiefMEQLicence)
rs("Tel") = Trim(Me.txtChiefMETel)
rs.Update
'清除文本框数据
Me.txtSCompName.Value = ""
Me.txtSCompAddress.Value = ""
Me.txtSQG.Value = ""
Me.txtSQLicence.Value = ""
Me.txtSTel.Value = ""
Me.txtChiefME.Value = ""
Me.txtChiefMEQLicence.Value = ""
Me.txtChiefMETel.Value = ""
Me.txtSCompName.SetFocus
rs.Close
Set rs = Nothing
ExitHere:
Exit Sub
HandleErrorSTel:
MsgBoxShow "“单位电话”填写有误", "请填写数字"
Resume ExitHere
HandleErrorChiefMETel:
MsgBoxShow "总监工程师“联系电话”填写有误", "请填写数字"
Resume ExitHere
红色代码部分无论我在文本框控件填写正确与否,都会来到最后处理错误的代码。如果我注释掉“HandleErrorChiefMETel:
”代码块,退出再运行则程序就跳到“HandleErrorSTel:”处理错误代码,就是说:只要你还有处理错误的代码存在,无论如何都会触发。求解。。。。。。。。。。我是那个地方写错了????
|
|