I have a loop that runs a SQL statment, and I'd like to run a variable through this statement, but I can't seem to find the correct syntax.
For example,
Dim T As String
T = "Table1"
DoCmd.RunSQL "SELECT " & T & ".* FROM " & T
The variable seems to disappear when I do this, so the statement goes through as SELECT .* FROM ... which of course fails.
I've tried putting brackets and parentheses around the variable but that doesn't make any difference. I need to use a variable as I'm running the statement through a loop and the name of the table changes with each run-through.
Any ideas?
For example,
Dim T As String
T = "Table1"
DoCmd.RunSQL "SELECT " & T & ".* FROM " & T
The variable seems to disappear when I do this, so the statement goes through as SELECT .* FROM ... which of course fails.
I've tried putting brackets and parentheses around the variable but that doesn't make any difference. I need to use a variable as I'm running the statement through a loop and the name of the table changes with each run-through.
Any ideas?