Write a record to a separate table

R

Razor

Hi,

Could someone show me how to write out a new record to a
table populating the fields using variables?

Thanks,

Razor
 
F

fredg

How would I write an append query in VBA?
Thanks, Fred!
I can't write it exactly for you as I haven't a clue as to what or to
where you are appending.

Make a new query.
After you add the table you wish to append from
Click on Query + Append
Enter the name of the table you wish to append to.

Continue with entering whatever fields and/or criteria you need.

On the Query View Tool Button, click on SQL View.
There is your Append SQL.
Copy it and use it in your VBA code.
Note: the SQL should be all on one line after you paste it.

DoCmd.RunSQL "Insert into tblToName Select tblFromName.* From
tblFromName;"

I hope this gets you started.

P.S. You can always simply save the append query and then just open it
from VBA...
DoCmd.OpenQuery "QueryName"

If you use the above, you will get a warning message that you are
about to append records Yes/No.
If you decide you do not want to give the user a means of canceling
the append, write
DoCmd.SetWarnings False
on the line before the query is run. Then
DoCmd.SetWarnings True
on the line after the query is run.
 

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