Hi Everyone
I have an SQL query statement built-up in Excel 2010 VBA, which updates a database, similar to below. I am using ADO and the command .Execute(stSQL) from within Excel VBA - works fine.

stSQL = "UPDATE Organisation " _
   & "SET Org_Ref = '" & usrformtextbox1.Value & "', " _
        & "Org_Name = '" & usrformtextbox2.Value & "', " _
        & "Contact_Lastname = '" & usrformtextbox3.Value & "', " _
        & "Contact_Firstname = '" & usrformtextbox4.Value & "', " _
        & "Org_Contact_Email = '" & usrformtextbox5.Value & "', " _
        & "Org_Contact_Tel = '" & usrformtextbox6.Value & "' " _
    & "WHERE Org_ID = " & prikey
I want to take this 'hard coded' query out of Excel, save it, and load it into the variable stSQL from a text file, when require, without any user intervention.

I have copy/pasted and saved this into a text file and I can read this back into the variable stSQL. In this way the query will NOT NOW RUN with .Execute(stSQL). It throws an error which I think comes SQL Server "Incorrect syntax near '&' "

If I manually "Insert" the same text file from the Excel VBE, Insert menu, File ... command, the variable stSQL/query runs OK.
I want the text file to be "imported/inserted/loaded" by VBA, assigned to the variable stSQL and run via VBA code with no user input.
Can anyone help with this please.

I have previously posted this http://stackoverflow.com/questions/1...lude-variables without any success.

With thanks
Barry