add records to a table by VBA programming

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am new on the VBA, but I want to add a record to inventorytransaction table
automatically(user need press a button to fire the event) after collecting
the individual field information from another table via form. Is this can be
done by VBA?
Which command should I look after?

Thanks.
 
use the database and recordset objects.

an example.

dim DBS as database 'delcare the database object
dim RST as recordset 'declare the recordset object

set DBS = currentdb 'set the object = to the current db
set RST = currentdb.openrecordset("tablename") 'set the recordset object =
the table you wish to work with

with RST 'use the with statement so you dont have to type rst.<method>
everytime
.addnew
.fields("fieldname").value = variable
.fields("fieldname").value = variable
.update
end with
 
Back
Top