LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 709
Default Relative path to Access database

I have an Excel workbook. I also have a macro that runs a saved query (.dqy)
on the network drive to bring data from the database into Excel worksheet.

My question is can I use a relative path for use in the macro and the query
file. ie ..\..\

Here is the code for the macro:

Sub UpdateReport12()
'
' UpdateReport12 Macro
' Macro recorded 21/06/2007 by Social Services
'

'
Sheets("Data").Select
Cells.Select
Selection.ClearContents
Selection.QueryTable.Delete
Range("A1").Select
With ActiveSheet.QueryTables.Add(Connection:= _
"FINDER;O:\Adult Community & Housing Services\Policy Performance &
Resources\Technology & Business Support\Support Services\Accident
Reporting\Accident & Incidents - Database\Reports\Report_1.2 - HSE.dqy" _
, Destination:=Range("A1"))
.Name = "Report_1.2 - HSE_2"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = True
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.Refresh BackgroundQuery:=False
End With
Sheets("report").Select
End Sub

Here is the code for the query file:

XLODBC
1
DSN=MS Access Database;DBQ=O:\Adult Community & Housing Services\Policy
Performance & Resources\Technology & Business Support\Support
Services\Accident Reporting\Accident & Incidents - Database\Reports\accident
reporting.mdb;DefaultDir=O:\Adult Community & Housing Services\Policy
Performance & Resources\Technology & Business Support\Support
Services\Accident Reporting\Accident & Incidents -
Database\Reports;DriverId=25;FIL=MS Access;MaxBufferSize=2048;PageTimeout=5;
SELECT Report_12_HSE_Reportable_diseases.MainDate,
Report_12_HSE_Reportable_diseases.Division,
Report_12_HSE_Reportable_diseases.`HSE Inc`,
Report_12_HSE_Reportable_diseases.incident_type,
Report_12_HSE_Reportable_diseases.type_of_person,
Report_12_HSE_Reportable_diseases.DivSplit,
Report_12_HSE_Reportable_diseases.DMBC FROM
Report_12_HSE_Reportable_diseases Report_12_HSE_Reportable_diseases


MainDate Division HSE Inc incident_type type_of_person DivSplit

Many thanks in advance.
--
Richard
 
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
Relative Path to a Folder Heliocracy Excel Discussion (Misc queries) 3 October 3rd 07 04:28 PM
Relative vs. Absolute Path Names for linked cell data Chef Sandra Excel Discussion (Misc queries) 0 April 11th 07 09:18 PM
Using Relative path for XML data file? Mark W. Robbins Charts and Charting in Excel 0 June 7th 06 06:41 AM
how to change absolute path to relative path hwijgerse Excel Worksheet Functions 0 November 25th 05 07:18 AM
Absolute vs Relative path K2H Excel Discussion (Misc queries) 2 July 28th 05 12:50 PM


All times are GMT +1. The time now is 08:58 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"