I have a combo box and some text boxes. When I make a selection from the combo box the text boxes are populated with the other fields in the recordset. I need to be able to edit one of the fields and save the update. In DAO I used to be able to use .edit followed by the text boxes, their corresponding field names and then .update. How do I do it in ADO. Any ideas? Here is my existing code. Thanks
Private Sub Combo1_click()
Dim conn As New ADODB.Connection
Dim rs As New ADODB.Recordset
With conn
.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\databases\ServersTest.mdb;Persist Security Info=False"
.Open
If .State = adStateOpen Then
'MsgBox "open"
Set rs = conn.Execute("SELECT * FROM equipment WHERE equipid = " + CStr(Combo1.ItemData(Combo1.ListIndex))) ', conn
If Not rs.EOF Then
Text1.Text = "" & rs("equipid"
Text2.Text = "" & rs("EquipmentName"
Text3.Text = "" & rs("Location"
Text4 = "" & rs("Service"
Infochanged = False
End If
rs.Close
Set rs = Nothing
Set conn = Nothing
End If
End With
End Sub
Private Sub Form_Load()
Dim conn As New ADODB.Connection
Dim rs As New ADODB.Recordset
With conn
.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\databases\ServersTest.mdb;Persist Security Info=False"
.Open
If .State = adStateOpen Then
'MsgBox "open"
Set rs = conn.Execute("SELECT * FROM Equipment"
While Not rs.EOF
Combo1.AddItem rs("EquipID"
Combo1.ItemData(Combo1.NewIndex) = rs("EquipID"
rs.MoveNext
Wend
Combo1.ListIndex = 0
rs.Close
conn.Close
Set rs = Nothing
Set conn = Nothing
End If
End With
End Sub
aspvbwannab
Private Sub Combo1_click()
Dim conn As New ADODB.Connection
Dim rs As New ADODB.Recordset
With conn
.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\databases\ServersTest.mdb;Persist Security Info=False"
.Open
If .State = adStateOpen Then
'MsgBox "open"
Set rs = conn.Execute("SELECT * FROM equipment WHERE equipid = " + CStr(Combo1.ItemData(Combo1.ListIndex))) ', conn
If Not rs.EOF Then
Text1.Text = "" & rs("equipid"
Text2.Text = "" & rs("EquipmentName"
Text3.Text = "" & rs("Location"
Text4 = "" & rs("Service"
Infochanged = False
End If
rs.Close
Set rs = Nothing
Set conn = Nothing
End If
End With
End Sub
Private Sub Form_Load()
Dim conn As New ADODB.Connection
Dim rs As New ADODB.Recordset
With conn
.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\databases\ServersTest.mdb;Persist Security Info=False"
.Open
If .State = adStateOpen Then
'MsgBox "open"
Set rs = conn.Execute("SELECT * FROM Equipment"
While Not rs.EOF
Combo1.AddItem rs("EquipID"
Combo1.ItemData(Combo1.NewIndex) = rs("EquipID"
rs.MoveNext
Wend
Combo1.ListIndex = 0
rs.Close
conn.Close
Set rs = Nothing
Set conn = Nothing
End If
End With
End Sub
aspvbwannab