Here's how the loop would look *without* variables - I've hardcoded
FirstName, LastName and Company
Do While Not rstSource.EOF
strSql = "INSERT INTO [tblTest] SELECT rst!FirstName " & _
"AS FirstName, rst!LastName AS LastName, rst!Company " & _
"As Company FROM tblSource"
db.Execute strSql
Loop
The problem is, I don't know what the rst items will be (not always
FirstName, etc.) I have other code that tests for the items and builds the
rst, but I don't know what they are. So I want to use variables like this:
'pseudo code
Do While Not rstSource.EOF
strSql = "INSERT INTO [tblTest] SELECT rst!strVar1 " & _
"AS " & strVar1 & ", rst!strVar2 AS " & strVar2 & ", rst!strVar3 " &
_
"As " & strVar3 & " FROM tblSource"
db.Execute strSql
Loop
But how do I get rst!strVar when strVar is a variable?
Thanks in advance.