Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using DAO and Recordset

Status
Not open for further replies.

JIL143

MIS
Feb 6, 2002
2
AU

I actually use the query method to get that particular row. There is no problem in getting that particular data and putting it in the recordset. The problem is that when I update it using this code. It don't update that particular row instead it updates whatever is in the first one. I.m wondering do I have to use "Update" to update it.

Private Sub cmdupdate_Click()
Set rst = New ADODB.Recordset
rst.Source = "CLIENT"
rst.CursorType = adOpenStatic
rst.LockType = adLockPessimistic
rst.ActiveConnection = _
"Provider=Microsoft.JET.OLEDB.4.0; " & _
"Data Source= " & App.Path & "\NA.MDB"
rst.Open Options:=adCmdTable

rst(0) = txtCName.Text
rst(1) = txtCAddress.Text
rst(2) = txtCPhone.Text
rst(3) = txtCFax.Text
rst(4) = txtCPostCode.Text
rst(5) = txtCNumber.Text

rst.Update
rst.Close
Set rst = Nothing

Dim answer As Integer
answer = MsgBox("Client details have been updated! " & (Chr(13)) & _
"Do you want to make another change?", _
vbYesNo + vbInformation + vbMsgBoxSetForeground, "Confirmed")
End Sub

TerpFan2001
Thanks for your replay
 
Use an SQL query to retrieve the record you want to update.
The way your code works ADO is opening your table and moving to the first record. It looks as though that is not necessarily the record you want to update but that is the record that receives the changes. So just substitute the table name with a query string and adcmdTable with adCmdText and then this code should work!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top