Update a field in table

M

Mike

Hi All,

How do I update a specific record by using codes.

The code is:

Dim db As DAO.Database
Dim username As Recordset

Set db = Currentdb
Set username = CurrentDb.OpenRecordset("User",
dbOpenDynaset)


With username
'What code do I need to add so that I can update the
username field with the userId'
End With



Thanks,

mike
 
A

Allen Browne

Use a SQL statement your recorset contains only the record you need to edit:

Set username = CurrentDb().OpenRecordset("SELECT * FROM User WHERE ...

Alternativley, you can FindFirst in the recordset, but that would be less
efficient than just fetching the one you need.
 
M

mike

Thanks
-----Original Message-----
Use a SQL statement your recorset contains only the record you need to edit:

Set username = CurrentDb().OpenRecordset("SELECT * FROM User WHERE ...

Alternativley, you can FindFirst in the recordset, but that would be less
efficient than just fetching the one you need.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.




.
 

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