添加字段的值,只能添加客户编号,日期,产品名称,后面的数量,单价,金额,总是无法添加进去,一直都是空白,代码贴下来,求解...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

解决方案 »

  1.   

    Adodc1.Recordset.UpdateBatch 试试
    把On Error GoTo errorhandler去掉,然后看看错误信息是什么
      

  2.   

    数据库的table的信息打上了,有没有触发器?
      

  3.   

    去掉On Error GoTo errorhandler:后提示
    多步操作产生错误,请检查每一步的状态值
      

  4.   

    Adodc1.Recordset.UpdateBatch 试试
        Rst.CursorLocation = adUseClient 有了么?
      

  5.   

    我换个思路测试了一下,txtdate字段,我设置了默认值为now()也就是不填写,就输入当前时间,结果是如果我老老实实输入当前的时间,就可以完整添加,反之,如果我tatdate这个日期字段,我留空,那么久只能添加上面说的3个字段,后面的数量,金额,单价,无法添加,求解决方法
      

  6.   

    日期字段必须是合法的日期,建议改用DTPicker作为输入控件
      

  7.   

    日期字段出错了,On Error GoTo errorhandler把后面的字段跳过去了