Modification of data in tabels form VB code

  • Thread starter Thread starter Pawel
  • Start date Start date
P

Pawel

Hello,

Is there a posibility to modify a data in tables from VB
code? I know that I can use SQL instructions. But can I
use pure VB code?

Thanks for any help.
 
Hello,

Is there a posibility to modify a data in tables from VB
code? I know that I can use SQL instructions. But can I
use pure VB code?

You can; open a Recordset based on the table and use the Edit and
Update methods:

Dim rs As DAO.Recordset
Dim db As DAO.Database
Set db = CurrentDb
Set rs = db.OpenRecordset("tablename", dbOpenDynaset)
<use FindFirst or otherwise get to the record you want to edit>
rs.Edit
rs!fieldname = <some new value>
rs!anotherfield = <a value>
rs.Update
rs.Close
Set rs = Nothing

Generally executing an Update query is simpler and more efficient,
however.
 
Back
Top