如何用VB代码实现acess表数据的修改

来源:百度知道 编辑:UC知道 时间:2024/05/28 19:42:45
在如图所示的窗体中,将修改过的值保存进acess表中,即acess表中的数据是修改后的数据。我只会用文本框修改一下,acess中的数据都不变啊!
我也知道,但具体的编程不会,Private Sub Command3_Click()
Frame1.Visible = False
Frame2.Visible = False
Frame3.Visible = False
Frame4.Visible = True
Frame5.Visible = False
Dim a As New ADODB.Connection
a.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=h:\毕业设计--王欣\工艺信息表.mdb;Persist Security Info=False"
a.Open
Dim t As New ADODB.Recordset
Dim ffff As String
ffff = "select distinct 成品表.jbcc ,成品表.spc , 成品表.xpc from 成品表,工艺方法表,加工部位表,产品表 where 成品表.gyff=工艺方法表.dh and 成品表.jgbw=加工部位表.dh and 成品表.cph=产品表.cph and 产品表.cpmc='" & Form1.Combo1.Text & "'and 加工部位表.jgbwmc= '" & Form1.Combo2.Text & "' and 工艺方法表.gyffmc= '" & Form1.Combo3.Text & "'"
'MsgBox ffff
Set t = a.Execute(ffff)
Text1.Text = t.Fields(0)
Text2.Text = t.Fields(1)
Text3.Text = t.Fields(2)
a.C

需要用update语句更新ACCESS表中的数据

ffff ="update 成品表 set jbcc=" & Text1.Text & ",spc=" & Text2.Text & ",xpc=" & Text3.Text " where .........."
后面的条件你自己写

再用
a.Execute ffff
就可以了