Question : Copy data from one table to another, the user deciding which fields go where.

We have lots of sets of data arriving in CSV files, they contain data.

The order of the data in the csv files changes from one file to another.

What I would like to do is to import the data into a "temporary" source table

Then display the temporary source table to the user in columns (tabular format)

Above each column I would have a combo box (field list of the destination table) (allowing the user to select where in the destination table that column of data should be put).

Then, this is the hard bit, I want to copy the data from this temporary table into the real table using the information in the combo boxes

Update and Append Queries don't seem to like variable containing the destination in them they seem to want plain text.

I reckon there are lots of ways to do this, so a two parter, which way and then how.

Open suggestions of better ways.

Deal is data coming in with colums in "random orders (files are a mix of CSV and Excel  but csv is fine)
Need a way the user can tell the application which column is which and it all get loaded nice and neat.

Answer : Copy data from one table to another, the user deciding which fields go where.

Once you've accomplished the import to the temp table and selection of output field names using combo boxes you talked about it is relatively simple to create your output table.  In the module that creates the output table you'd build an SQL string similar to the attached code snippet
1:
2:
3:
4:
5:
6:
7:
strSQL = "SELECT " & _
			"Field1 as " & me.combobox1.value & ", " & _
			"Field2 as " & me.combobox2.value & ", " & _
			"Field3 as " & me.combobox3.value & " " & _
		"INTO OutputTable"
		
DoCmd.RunSQL strSQL
Random Solutions  
 
programming4us programming4us