Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding records from one table to another 2

Status
Not open for further replies.

ronphx

Programmer
Jun 24, 2004
64
US
I have a form that creates records in a temporary table in an invoice (tbltemporary). When I accept the invoice I want to add all the fields from all the records from the temporary table to the permanent invoice table (tblinvoice). I'm thinking I should use the Insert Into command from runsql. Is that right? I can't get the syntax.

Can someone help please?

Thanks.
 
Ronphx,

Try:
INSERT INTO tblinvoice(field1, field2, field3)
SELECT field1, field2, field3
FROM tbltemporary;

Hope this helps!
 
I can't get the syntax
In a blank SQL view pane, type INSERT and press the F1 key.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thanks to both of you. It works fine now, and I've figured out the syntax. I also read from the SQL view that I could use the wild card to add the fields so I didn't have to list them as long as the field names were the same in both tables.

Thanks again.
 
as long as the field names were the same in both tables.
No, as long as the field types were the same.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
I didn't know that - good to know. Does that mean it would put fields from the temporary file to the corresponding column (1,2,3,4 etc) of the permanent file as long as they were the same field types even if the field names were different?
 
Exactly, in the column order.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top