VB中实时错误-2147217904 :至少有一个参数没有指定值(80040e10)
Private Sub Command1_Click()
Dim rs_addtax As New ADODB.Recordset
Dim cnn As New ADODB.Connection
Dim sql As String
If Trim(Combo1.Text) = "" Then
MsgBox "请选择税种类别!", vbOKOnly + vbExclamation, ""
Combo1.SetFocus
Exit Sub
End If
If Trim(Combo3.Text) = "" Then
MsgBox "请选择纳税管理区!", vbOKOnly + vbExclamation, ""
Text2.SetFocus
Exit Sub
End If
If Not IsDate(Text5.Text) Then
MsgBox "请按照yyyy-mm-dd格式输入登记日期", vbOKOnly + vbExclamation, ""
Text5.SetFocus
Exit Sub
End If
cnn.Open "provider=Microsoft.Jet.OLEDB.4.0; data source=" & App.Path & "\tax.mdb"
sql = "select * from 纳税信息 where 纳税编号='" & Text1.Text & "'"
rs_addtax.Open sql, cnn, adOpenKeyset, adLockPessimistic
If rs_addtax.EOF Then
rs_addtax.AddNew
rs_addtax.Fields(0) = Trim(Text1.Text)
rs_addtax.Fields(1) = Trim(Combo1.Text)
rs_addtax.Fields(2) = Trim(Text6.Text)
rs_addtax.Fields(3) = Trim(Text7.Text)
rs_addtax.Fields(4) = Trim(Text2.Text)
rs_addtax.Fields(5) = Trim(Text3.Text)
rs_addtax.Fields(6) = Trim(Text4.Text)
rs_addtax.Fields(7) = Trim(Text5.Text)
rs_addtax.Fields(8) = Trim(Combo3.Text)
rs_addtax.Fields(9) = 0
rs_addtax.Update
MsgBox "纳税增加成功!", vbOKOnly, ""
rs_addtax.Close
Else
MsgBox "纳税编码重复!", vbOKOnly + vbExclamation, ""
Text1.SetFocus
rs_addtax.Close
End If
Exit Sub
End Sub
下面判断纳税编码是否重复时连接数据库取字段的部分。
cnn.Open "provider=Microsoft.Jet.OLEDB.4.0; data source=" & App.Path & "\tax.mdb"
sql = "select * from 纳税信息 where 纳税编号='" & Text1.Text & "'"
rs_addtax.Open sql, cnn, adOpenKeyset, adLockPessimistic(此处高亮显示,爆出如题错误) "select * from 纳税信息 where 纳税编号='" & Text1.Text & "'"
检查表名,字段名是否和数据库一致
sub text1_changed
on error resume next
text3=cstr(val(text1)-val(text2))
end sub
sub text2_changed
on error resume next
text3=cstr(val(text1)-val(text2))
end sub