|
Private Sub CommandButton1_Click()
Dim RS1 As Recordset
Dim DB1 As Database
Set DB1 = OpenDatabase(ThisWorkbook.Path & "\" & "TEST.MDB")
Set RS1 = DB1.OpenRecordset(Name:="数据库", Type:=dbOpenDynaset)
With RS1
.FindFirst "编号='" & TextBox1.Value & "'"
.AddNew
.Fields("编号").Value = Me.TextBox1.Value
.Fields("Account Code").Value = Me.TextBox2.Value
.Fields("公司名称").Value = Me.TextBox3.Value
.Fields("公司地址").Value = Me.TextBox4.Value
.Fields("城市").Value = Me.ComboBox1.Value
.Fields("邮编").Value = Me.TextBox5.Value
.Fields("收件人").Value = Me.TextBox6.Value
.Fields("联系电话").Value = Me.TextBox7.Value
.Update
' RS1.FindFirst "姓名='" & TextBox2.Value & "'"
MsgBox "增加 [ Account:" & TextBox2.Value & " " & TextBox3.Value & " ] 的信息成功!目前共有记录" & RS1.RecordCount & "条", 1 + 16, "添加成功"
End With
DB1.Close
Set RS1 = Nothing
Set DB1 = Nothing
End Sub
请教给位老大,黄色部分运行的时候总是提示方法和数据成员未找到,是什么原因?是不是其他还有地方代码有问题?
该贴已经同步到 jiangdong110的微博 |
|