I am trying to run a dynamic query but with no success...Here is the code,,
Code: ( text )
Function Test(fsHistoryId As String, fsTemplateId As String)
Dim lsSqlToRun As String
Dim db As DAO.Database
Set db = CurrentDb()
lsSqlToRun = "Select * INTO tblTemp from " & fsTemplateId & " where historyid = '" & fsHistoryId & "';"
The above code when run is doing nothing. It is not inserting any rows into the temp table.
When I use the text from this variable and execute the sql separately, it works. I am not sure what is wrong with the above code. I need to pass the table name as a variable. Any ideas on what could be wrong. Thank you for the help in advance.