Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default Changing Query source location?

oops!

just reviewing my own code... and I fear I forgot to update
the actual Connection string..

but if you'd do following you might get a result... sorry!

Set qTbl = ActiveSheet.QueryTables(1)
sCon = qTbl.Connection
qTbl.Connection = WorksheetFunction.Substitute(sCon, sOld, sNew)
qTbl.Refresh



keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


keepitcool wrote:

Download Flexfind from this site..

http://www.bmsltd.co.uk/MVP/MVPPage.asp

If you want to do it with VBA you'll have to do s'thing similar to
following:

Sub ChangeQtSource()
Dim qTbl As QueryTable
Dim sCon As String
Dim sOld As String
Dim sNew As String

sOld = "c:\databases"
sNew = "d:\shared\databases"

Set qTbl = ActiveSheet.QueryTables(1)
sCon = qTbl.Connection
WorksheetFunction.Substitute sCon, sOld, sNew
qTbl.Refresh

End Sub





keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


"Jennifer Crawford" wrote:

I have set up an Excel worksheet so that it pulls data
from an Access database when the user fills out two cells.

When I distribute this worksheet, the location for the
Access database will have changed.

Is there a way for me to somehow programatically update
the location for the Query source (database) without
having to manually go recreate the query to point to the
new source?

I should note that I have tried to actually manually
overwrite the path name for the database in the Query SQL
window, but this still gives me errors.

Thanks!

Jennifer Crawford





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
link not updating after changing source location Fred Excel Discussion (Misc queries) 0 October 11th 07 06:05 PM
Changing query data source TonyL Excel Discussion (Misc queries) 1 July 4th 07 04:44 PM
Changing data source on ODBC query Aussie CPA Excel Discussion (Misc queries) 2 June 14th 07 05:44 PM
changing query source [email protected] Excel Worksheet Functions 2 March 21st 06 08:55 PM
Query source location - how do I change? Jennifer Crawford Excel Programming 1 August 1st 03 09:14 AM


All times are GMT +1. The time now is 11:28 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"