Inserting Records in Access

D

Dick Schroth

You can just do it through a SQL statement, either one
row at a time or a whole recordset in one shot.
Something like:

' all at once
strSQL = "INSERT INTO TableB (Fld1, Fld2) SELECT Fld1,
Fld2 FROM TableA"
DoCmd.RunSQL strSQL

or

' one at a time
strSQL = "INSERT INTO TableB (Fld1, Fld2) Values ('" &
Var1 & "', '" & Var2 & "')"
DoCmd.RunSQL strSQL

For numeric fields you wouldn't enclose the variables in
single quotes. To get the values you want into the
variables you would have to open a recordset and loop
through it, but there are lots of examples in the VBA
help to show you how to do that.

Hope this helps!

Dick
 

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