On Error goto解决办法

On Error gotoVB codeOn Error GoTo ErrSet sql kucun.Execute(select * from 采购信息 where 采购合同

On Error goto

VB code
On Error GoTo ErrSet sql = kucun.Execute("select * from 采购信息 where 采购合同号='" & Text1(0).Text & "' and 产品型号='" & Text1(1).Text & "'")If sql.EOF Then '没有相同记录,可以添加kucun.Execute "insert into 采购信息 (采购合同号,产品型号,数量,单价,合同日期,到货日期,到货数量,发票类型,发票金额) values ('" & Text1(0).Text & "','" & Text1(1).Text & "'," & Text1(2).Text & ",convert([money],'" & Text1(3).Text & "'),'" & DTPicker1(0).Value & "','" & DTPicker1(1).Value & "'," & Text1(6).Text & ",'" & Combo1.Text & "',convert([money],'" & Text1(6).Text & "'))"Unload MeElseMsgBox "库存中已有该采购合同号和产品型号的记录,请点击修改按钮对其修改", vbCritical, "财务管理"Exit SubEnd IfErr:         MsgBox "对不起,出现未知错误,请检查信息", vbInformation, "错误提示"End Sub

我想让他先执行我的判断之后,再进行Err判断

[解决办法]
不可能
[解决办法]
如果你的判断之前没有异常,它也不会影响你的判断,如果你的判断之前出现了异常,你的判断还能执行吗?
[解决办法]
探讨
现在的问题是我没错他也执行Err了

[解决办法]
On Error GoTo Err

Set sql = kucun.Execute("select * from 采购信息 where 采购合同号='" & Text1(0).Text & "' and 产品型号='" & Text1(1).Text & "'")
If sql.EOF Then '没有相同记录,可以添加
kucun.Execute "insert into 采购信息 (采购合同号,产品型号,数量,单价,合同日期,到货日期,到货数量,发票类型,发票金额) values ('" & Text1(0).Text & "','" & Text1(1).Text & "'," & Text1(2).Text & ",convert([money],'" & Text1(3).Text & "'),'" & DTPicker1(0).Value & "','" & DTPicker1(1).Value & "'," & Text1(6).Text & ",'" & Combo1.Text & "',convert([money],'" & Text1(6).Text & "'))"
Unload Me
Else
MsgBox "库存中已有该采购合同号和产品型号的记录,请点击修改按钮对其修改", vbCritical, "财务管理"
End If
Exit Sub '这样就可以了
Err:
MsgBox "对不起,出现未知错误,请检查信息", vbInformation, "错误提示"
End Sub