update/edit records

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
 
A

Ayelet

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top