Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

changing database in MS Query 1

Status
Not open for further replies.

mehlerak

IS-IT--Management
Dec 10, 2003
52
US
I need to create an excel spreadsheet with an embedded query, built using MS Query. When building the query, it asks which database to point at. If I need to send the excel spreadsheet to somebody when I'm done to use the spreadsheet and query on their own database (thus changing the database the query is pointing to), how would I go about doing this? I can't seem to find any way to change the target database once the query is embedded in the spreadsheet.
Thanks
 
Turn on the macro recorder...and go through all of the steps of editing your query and returning the data to your sheet...

stop the recorder and view the code created.(alt+F11)

the SQL string in the code can be concatenated to -splice in- a variable, such as a response from an inputbox or cell ref. (in your case it would be the database path\file\query or table...etc.)


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top