By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,705 Members | 1,845 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,705 IT Pros & Developers. It's quick & easy.

Dynamic query

P: 9
I am trying to run a dynamic query but with no success...Here is the code,,
Expand|Select|Wrap|Line Numbers
  1. Function Test(fsHistoryId As String, fsTemplateId As String)
  2.     Dim lsSqlToRun As String
  3.     Dim db As DAO.Database
  4.     Set db = CurrentDb()
  5.  
  6.     lsSqlToRun = "Select * INTO tblTemp from " & fsTemplateId & " where historyid = '" & fsHistoryId & "';"
  7.  
  8.  
  9.     db.Execute lsSqlToRun
  10.  
  11. End Function
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.
Jan 14 '08 #1
Share this Question
Share on Google+
1 Reply


P: 9
Ignore this post. I got it working.
Jan 14 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.