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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Transporting Access SQL code to Excel

Status
Not open for further replies.

UWTechie

Programmer
May 24, 2001
18
0
0
CA
When I am in Excel, I can link to an Access Query, and then move the information over to the Excel. What I need to learn is how to get the raw SQL from that Access Query moved to the Excel sheet, thus taking away a bit of the dependency that the excel sheet has on the location of the mdb. I know that I can just go an open the Query, in Access, and then copy&paste the SQL into the Excel sheet, but is there some way to do it straight from Excel?

Or, do any of you perhaps know any methods to take away the dependency that a spreadsheet has on the name/location of an mdb that it is taking data from? Perhaps some way of either automating an update that autmatically changes the path from the Excel sheet to the Access mdb, whenever the name or location of the mdb is changed? Or even some sort of abstract naming convention, that will let you change the name of the mdb, without changing the actual path that the link takes?

Everyone, I would really appreciate your input on this. Thanx alot...

 
Attach this code to your sheet...

Sub SQL()

Let Range("A1").Value = Sheets("Lost Mumbai Calls").QueryTables("ExternalData1").SQL

End Sub

Then all you have to do is go Tools, Macros and run this code.

Good luck!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top