View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jennifer Crawford Jennifer Crawford is offline
external usenet poster
 
Posts: 6
Default Changing Query Source Location?

-----Original Message-----
Are you sure your query is named MyQuery?


Actually, my query has no name at all, so using the number
instead of the name worked much better. That at least
allowed me to get the connection string - which is one
step further than where I was before!

So.

Using some code Rob Rutherford gave me as a sample
earlier, I tried the following to reset the connection:

Function ChangePath()
Dim str As String
str = "ODBC;DSN=MS Access Database;DBQ="
str = str & "C:\Jennifer\ProjectOrganizer.mdb;"
ActiveSheet.QueryTables(1).Connection = str
End Function

This function compiles with no errors.

However, when I try to run it from the Immediate window, I
get this error:

"Compile error: Expected = "

And obviously, it doesn't update the connection.

I'm not sure where this should even be called, quite
frankly, or how to set it up.