用data控件连接的数据库,怎样将记录指针定位到符合条件的那条记录,比如说要定位到“客户ID”为txtusername.text(文本框,用户输入的客户ID)并且“月份”为txtmonth(文本框,用户输入的月份)的那条记录,然后进行编辑?
data1.recordset.findfirst "客户ID='" & txtusername.text & " ' " and "月份='" & txtmonth.text & " ' "
data1.recordset.edit (客户ID和月份为数据库中表的字段,data控件已经绑定了其中的一张表)
...........
以上代码应该怎样修改?

解决方案 »

  1.   

    data1.recordset.edit改为
    data1.recordset.fields("A1") = "A1"
    data1.recordset.fields("A2") = "A2"
    ---------
    data1.recordset.update
      

  2.   

    private sub cmdFind_Click()
    data1.recordset.findfirst "客户ID='" & txtusername.text & "' and 月份='" & txtmonth.text & "'"if data1.recordset.nomatch then
        msgbox "无此记录"
    else
        cmdEdit.Enabled = True
    End If
    end subPrivate sub cmdEdit_Click()
    data1.recordset.edit
    ......
    data1.recordset.update
    cmdEdit.Enabled = False
    end sub