Results 1 to 4 of 4
  1. #1
    2 Star Lounger
    Join Date
    Feb 2003
    Location
    Melbourne, Victoria, Australia
    Posts
    139
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default to databse folder (Access 2000 SR-1)

    I have a linked text file within a database.
    If I move that database to a new folder I have to recreate that link to point to the same file, but in the new folder.
    I also have an export function (see below) which creates the required Excel file in the current folder.
    How can I create a link which looks for a particular named file in thecurrent folder,
    and how do I create an Excel file in the current folder without specifying the path.

    Sub ADIJournalExport()
    Dim stExportDocName As String
    Dim stDocName As String

    stExportDocName = "Cocuments and SettingsmlhMy DocumentsFixedAssetsFundCodesEOM_Corrected"
    stDocName = "qryADI_EOMJournal"

    DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, stDocName, stExportDocName

    End Sub

    Thanks in advance

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Default to databse folder (Access 2000 SR-1)

    The path to linked tables is always hard-coded, so you must update the link if you move the file you link to. The Developer Solutions Sample database from Microsoft contains example code that demonstrates how to update links when the database is opened. See Sample Applications Download.

    CurrentProject.Path returns the path of the current database, so you could use

    stExportDocName = CurrentProject.Path & "EOM_Corrected"

  3. #3
    2 Star Lounger
    Join Date
    Feb 2003
    Location
    Melbourne, Victoria, Australia
    Posts
    139
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Default to databse folder (Access 2000 SR-1)

    Thanks Hans,
    Used CurrentProject.Path, and it it works like a dream.
    Can't find where to download the Solutions9.mdb from Microsoft using your link or from within Microsoft.
    I will see if the 'Heldesk' team will provide me with a copy as, this is not installed as part of the Standard Operating Environment.
    Thanks again
    Michael

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Default to databse folder (Access 2000 SR-1)

    Oops, the link I provided used to contain the download link, but apparently MS has withdrawn it. Sorry about that. I have attached the relevant module as a text file. It will have to be adapted for your purposes, since the code is meant to update links to another Access database.
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •