update/edit records

  • Thread starter Thread starter Eric W.
  • Start date Start date
E

Eric W.

I need to be able to update/edit records in a database. I
know how to get the data from my excel spreadsheets and
append the data, I'm just not sure how to edit a record.
Any example help will be greatly appreciated. Thanks in
advance!

Eric W.
Madison, WI
 
Hi,
Try this:
'code start
Dim DB as DAO.Database
Dim RS As DAO.RecordSet

Set DB = CurrentDB()
Set RS = DB.OpenRecordset("MyTableName",dbOpenDynaset)
'you could also use an SQL clause instead of the table name

RS.FindFirst("[MyID] = " & lngMyRecordID)
If RS.NoMatch Then
MsgBox "Record Not Found"
Exit Sub
End If
'To Edit a record
Rs.Edit
Rs![Field1] = Field1Val
Rs![Field2] = Field2Val
....
Rs.Update
End Sub
'Code Ends

HTH,
Ayelet
 
Back
Top