Hi All,
I need to export a query (with parameters) to create a varying number of different tables in an external database. I think the best way to do this is to dynamically build and execute a SQL Statement within a loop.
I am having a curious problem, in that it lets me assign the query I need to my string the first time, but the second time I get
I am stumped as to why I am not able to reassign this variable.
Here is the basic structure of my code (I will spare you the SQL statement it is a few lines)
Any thoughts much appreciated.
Thanks,
Alex
I don't do any programming whatsoever
Ignorance of certain subjects is a great part of wisdom
I need to export a query (with parameters) to create a varying number of different tables in an external database. I think the best way to do this is to dynamically build and execute a SQL Statement within a loop.
I am having a curious problem, in that it lets me assign the query I need to my string the first time, but the second time I get
Run Time Error '5':
Invalid Procedure Call or Argument
I am stumped as to why I am not able to reassign this variable.
Here is the basic structure of my code (I will spare you the SQL statement it is a few lines)
Code:
Dim x As Integer
Dim strSQL As String
For x = LBound(MMYY) To UBound(MMYY)
strSQL = "select some, columns " _
& "into '" & dbName & "' " _
& "from someTable inner join another " _
& "on someTable.PK = another.PK " _
& "where someTable.BirthMonth = " & left(MMYY(x), 2) _
& " someTable.BirthYear = " & right(MMYY(x), 4)
DoCmd.RunSQL strSQL
Next
Any thoughts much appreciated.
Thanks,
Alex
I don't do any programming whatsoever
Ignorance of certain subjects is a great part of wisdom