Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
I used a query in Excel to link to an Access query.
The problem is that when I moved the files to a new folder, I could no longer refresh the external data (excel was still looking for the *.mdb file in the old folder). Is it possible to use a relative location for the db file, instead of an absolute location? It will always be in the same folder as the excel file. Thanks, ~ Horatio |
#2
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
hi
the file path to the access query is hard coded into the sql of the excel query. you must change the file path to the new location. but from my experience and from a number of posts to this forum, changing the file path in the sql doesn't seem to work as expected. the excel query still points at the old location. so i always just delete the old query in excel and create a new query for the new location. yeah, i know. sucks. so my best advise is to have someone spank your hands everytime you get into the mood of moving something. Regards FSt1 "Horatio J. Bilge, Jr." wrote: I used a query in Excel to link to an Access query. The problem is that when I moved the files to a new folder, I could no longer refresh the external data (excel was still looking for the *.mdb file in the old folder). Is it possible to use a relative location for the db file, instead of an absolute location? It will always be in the same folder as the excel file. Thanks, ~ Horatio |
#3
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Thanks for the advice.
"FSt1" wrote: hi the file path to the access query is hard coded into the sql of the excel query. you must change the file path to the new location. but from my experience and from a number of posts to this forum, changing the file path in the sql doesn't seem to work as expected. the excel query still points at the old location. so i always just delete the old query in excel and create a new query for the new location. yeah, i know. sucks. so my best advise is to have someone spank your hands everytime you get into the mood of moving something. Regards FSt1 "Horatio J. Bilge, Jr." wrote: I used a query in Excel to link to an Access query. The problem is that when I moved the files to a new folder, I could no longer refresh the external data (excel was still looking for the *.mdb file in the old folder). Is it possible to use a relative location for the db file, instead of an absolute location? It will always be in the same folder as the excel file. Thanks, ~ Horatio |
#4
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
I came up with a solution.
I wrote the query as a macro (using macro recorder for help). Then I used the workbook path where needed in the query, since the workbook path and the database path will always be the same. It looks like this: Sub Query_1() Dim sPath As String sPath = ThisWorkbook.Path With ActiveSheet.QueryTables.Add(Connection:=Array(Arra y( _ "ODBC;DSN=MS Access Database;" & _ "DBQ=" & sPath & "\MyDB.mdb;" & _ ' etc... I went through the query code, and ' inserted sPath into the code wherever needed, ' just like the "DBQ=..." line above. ' End With End Sub "FSt1" wrote: hi the file path to the access query is hard coded into the sql of the excel query. you must change the file path to the new location. but from my experience and from a number of posts to this forum, changing the file path in the sql doesn't seem to work as expected. the excel query still points at the old location. so i always just delete the old query in excel and create a new query for the new location. yeah, i know. sucks. so my best advise is to have someone spank your hands everytime you get into the mood of moving something. Regards FSt1 "Horatio J. Bilge, Jr." wrote: I used a query in Excel to link to an Access query. The problem is that when I moved the files to a new folder, I could no longer refresh the external data (excel was still looking for the *.mdb file in the old folder). Is it possible to use a relative location for the db file, instead of an absolute location? It will always be in the same folder as the excel file. Thanks, ~ Horatio |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Create a database query that does not reference an IP address. | Excel Discussion (Misc queries) | |||
database query not showing foxpro database How I import data | New Users to Excel | |||
How do I avoid excel change absolute address to relative address | Excel Discussion (Misc queries) | |||
what is difference between absolute address and relative address? | Excel Discussion (Misc queries) | |||
How to use a Access Query that as a parameter into Excel database query | Excel Discussion (Misc queries) |