Results 1 to 6 of 6
  1. #1
    recyan's Avatar
    recyan is offline Expert
    Windows 2K Access 2000
    Join Date
    Dec 2011
    Posts
    662

    Standard Path for files to be called in VBA

    The Background :
    I have a folder (mydb) with an access db in it.
    This folder also has a couple of files ( image files ( myImage.jpg), doc files, etc ) in it.
    These files are called in VBA in a module in the db.

    The Problem :
    The path for a file in VBA on my computer is something like :
    <img src='D:\my Data\Docs\mydb\myImage.jpg'" & "width='330' height='200'>"

    Now if I want to test on a different computer, the path unfortunately most of the times is bound to be different.



    Is it possible to avoid having to change the path in VBA, every time I work on a different desktop?

    Thanks

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,633
    The folder is located on central shared server? Try UNC pathing: \\servername\path\filename
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    recyan's Avatar
    recyan is offline Expert
    Windows 2K Access 2000
    Join Date
    Dec 2011
    Posts
    662
    No. These are totally different independent desktops.
    For eg.
    On my Computer, the path :
    <img src='D:\my Data\Docs\mydb\myImage.jpg'" & "width='330' height='200'>"

    On a second Computer, the path could be :
    <img src='C:\My Documents\mydb\myImage.jpg'" & "width='330' height='200'>"

    On a third Computer, the path could be :
    <img src='E:\Personal Docs\mydb\myImage.jpg'" & "width='330' height='200'>"

    Thanks
    Thanks

  4. #4
    recyan's Avatar
    recyan is offline Expert
    Windows 2K Access 2000
    Join Date
    Dec 2011
    Posts
    662
    Think I may have got it :
    Perhaps use below to get the access db Folder Path & then concatenate the file name with extension.

    "Application.CurrentProject.Path"

    Thanks

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,633
    So the folder could be anywhere, even on user's local drive?

    Oh, just read the OP again - the db and the files will always be side-by-side in the same folder?

    Try:

    "<img src='" & CurrentProject.Path & "\myimage.jpg' width='330' height='200'>"
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    recyan's Avatar
    recyan is offline Expert
    Windows 2K Access 2000
    Join Date
    Dec 2011
    Posts
    662
    Yes June. Tested it. It works on my comp.
    Should be able to test it on a different comp later.
    Will keep you posted.

    Thanks

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 4
    Last Post: 08-19-2014, 12:20 PM
  2. Replies: 6
    Last Post: 05-27-2014, 05:41 AM
  3. Replies: 3
    Last Post: 11-24-2012, 08:56 AM
  4. Replies: 2
    Last Post: 11-08-2012, 11:04 AM
  5. relink to relative path TXT data files
    By tobynegus in forum Programming
    Replies: 0
    Last Post: 08-19-2008, 10:10 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums