append query vs SQL INSERT

  • Thread starter Thread starter Gregg
  • Start date Start date
G

Gregg

I want to insert records into an Access 2003 .mdb table.
Append queries don't seem to fit since I will be
inserting different numbers of records depending on user
input in a form. Creating a module using INSERT from SQL
in a loop seems perfect, but I can't find how to execute
the SQL statement that I would assemble in that loop. Is
there a RunSql command or something similar? Thanks!
 
Try:
dbEngine(0)(0).Execute "INSERT ...", dbFailOnError

You can use DoCmd.RunSql, but you don't know if it succeeded.

With the Execute method, you can also examine RecordsAffected (the number of
inserts), and even use a transaction for an all-or-nothing result.
Transaction details and example:
http://allenbrowne.com/ser-37.html
 
Back
Top