Merging tables and data and inserting into another table (1 Viewer)

JC10001

Registered User.
Local time
Today, 22:28
Joined
Sep 24, 2003
Messages
48
Inserting portions of a table and data into another table

Hello. I would like to take an entire column of values from a table (lets call it table1) and a value that a user enters on a form and merge them together and then insert them into another table.

So if table1 contains:
-------------------------------
1
2
3
4
5

And the user enters:
--------------------------------
A


I would like to insert the following into a pre-existing table:
-----------------------------------------------------------------------------------

Column1..........Column 2
-------------- ------------------
1.......................A
2.......................A
3.......................A
4.......................A
5.......................A

Can anyone help me out? I'm having a heck of a time.
 
Last edited:

JC10001

Registered User.
Local time
Today, 22:28
Joined
Sep 24, 2003
Messages
48
Anyone??

Here is what I have so far. I keep getting an error saying that I need to add an exists statement. Where exactly am I supposed to put one?

strsql = "Insert into tableA Values((SELECT * FROM tableB), " & cmb_box.Column(0) ");"

DoCmd.RunSQL strsql
 

JC10001

Registered User.
Local time
Today, 22:28
Joined
Sep 24, 2003
Messages
48
I was able to figure things out eventually. Here is the solution in case anyone comes across this thread in the future:

strsql = "Insert into tableA SELECT tableB.Variable1, tableB.Variable2, " & combo_box.Column(0) & " as VariableA FROM tableB;"

DoCmd.RunSQL strsql

The syntax was quite different than what I was used to.
 

Users who are viewing this thread

Top Bottom