|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
- Private Sub CommandButton1_Click()
- Dim RS1 As Recordset
- Dim DB1 As Database
-
- Set DB1 = OpenDatabase(ThisWorkbook.Path & "" & "Info.MDB")
- Set RS1 = DB1.OpenRecordset(Name:="信息", Type:=dbOpenDynaset)
- With RS1
-
- .AddNew
- .Fields("工号").Value = Me.TextBox1.Value
- .Fields("部门").Value = Me.ComboBox1.Value
- .Fields("姓名").Value = Me.TextBox2.Value
- .Fields("性别").Value = Me.ComboBox2.Value
- .Fields("电话").Value = Me.TextBox3.Value
- .Update
- MsgBox "增加 [ 工号:" & TextBox1.Value & " 姓名:" & TextBox2.Value & " ] 的信息成功!目前共有记录" & RS1.RecordCount & "条", 1 + 16, "添加成功"
-
-
- End With
- DB1.Close
- Set RS1 = Nothing
- Set DB1 = Nothing
- End Sub
复制代码- Private Sub CommandButton1_Click()
- Dim RS1 As Recordset
- Dim DB1 As Database
-
- Set DB1 = OpenDatabase(ThisWorkbook.Path & "" & "Info.MDB")
- Set RS1 = DB1.OpenRecordset(Name:="信息", Type:=dbOpenDynaset)
- With RS1
-
- .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
- MsgBox "增加 [ Account:" & TextBox2.Value & " " & TextBox3.Value & " ] 的信息成功!目前共有记录" & RS1.RecordCount & "条", 1 + 16, "添加成功"
-
- End With
-
- DB1.Close
- Set RS1 = Nothing
- Set DB1 = Nothing
- End Sub
复制代码
请教各位大大,上面两段代码基本上一模一样,请问为什么下面这一段不可以运行。 |
|