Results 1 to 2 of 2

Thread: dynamic query

  1. #1
    Join Date
    Apr 2007

    Unanswered: dynamic query

    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 & "';"

    db.Execute lsSqlToRun

    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.

  2. #2
    Join Date
    Apr 2007
    Please ignore this post. I got it working.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts