添加字段的值,只能添加客户编号,日期,产品名称,后面的数量,单价,金额,总是无法添加进去,一直都是空白,代码贴下来,求解...Private Sub cmdadd_Click()
On Error GoTo errorhandler:
If txtno.Text <> "" Then
Adodc1.Recordset.AddNew
Adodc1.Recordset.Fields("客户编号") = txtno.Text
Adodc1.Recordset.Fields("产品名称") = txtname.Text
Adodc1.Recordset.Fields("日期") = txtdate.Text
Adodc1.Recordset.Fields("数量") = Val(txtnum.Text)
Adodc1.Recordset.Fields("单价") = Val(txtprice.Text)
Adodc1.Recordset.Fields("金额") = Val(txtall.Text)
Adodc1.Recordset.Update
cmbname.Clear
Adodc1.RecordSource = "HXKH"
Adodc1.Refresh
Do While Not Adodc1.Recordset.EOF
cmbname.AddItem Adodc1.Recordset.Fields(1)
Adodc1.Recordset.MoveNext
Loop
cmbfield_Click
cmbclear_Click
Else
MsgBox "客户编号是主索引字段,不能为空.", , "错误提示"
End If
Exit Sub
errorhandler: MsgBox "客户编号是主索引字段,不能为空.", , "错误提示"
End Sub
On Error GoTo errorhandler:
If txtno.Text <> "" Then
Adodc1.Recordset.AddNew
Adodc1.Recordset.Fields("客户编号") = txtno.Text
Adodc1.Recordset.Fields("产品名称") = txtname.Text
Adodc1.Recordset.Fields("日期") = txtdate.Text
Adodc1.Recordset.Fields("数量") = Val(txtnum.Text)
Adodc1.Recordset.Fields("单价") = Val(txtprice.Text)
Adodc1.Recordset.Fields("金额") = Val(txtall.Text)
Adodc1.Recordset.Update
cmbname.Clear
Adodc1.RecordSource = "HXKH"
Adodc1.Refresh
Do While Not Adodc1.Recordset.EOF
cmbname.AddItem Adodc1.Recordset.Fields(1)
Adodc1.Recordset.MoveNext
Loop
cmbfield_Click
cmbclear_Click
Else
MsgBox "客户编号是主索引字段,不能为空.", , "错误提示"
End If
Exit Sub
errorhandler: MsgBox "客户编号是主索引字段,不能为空.", , "错误提示"
End Sub
把On Error GoTo errorhandler去掉,然后看看错误信息是什么
多步操作产生错误,请检查每一步的状态值
Rst.CursorLocation = adUseClient 有了么?