Results 1 to 12 of 12
  1. #1
    Join Date
    Aug 2007
    Location
    Ireland
    Posts
    13

    Unanswered: Access 2000 - Relative addressing

    Hi,
    I have a database that is working fine. To display images in the database and reduce the file size of the database I use a field in tblemployees to state the local location of the image, i.e d:\img\person1.jpg. This image is then displayed in a form with other details on the employee.

    What I would like to know is can I use relative addressing (similar to HTML i.e. ./img/person.jpg). Is there a technique to say "look in the current directory for the image".

    Zedekiah.

  2. #2
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    CurrentProject.Path will return the path your database resides in.

    Linq
    Last edited by Missinglinq; 08-19-07 at 07:56.
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  3. #3
    Join Date
    Aug 2007
    Location
    Ireland
    Posts
    13
    Hi Linq,
    Thank you for the speedy reply.

    Does CurrentProject.Path need to be used in a VB or VBA environment. I have little experience with these tools.

    Do you know of an example of this code on action. I'm afraid I am the type that needs to play with code to understand it.

    Zedehiak.

  4. #4
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    Use CurrentProject.Path & "\person1.jpg" wherever you had it stored before.
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  5. #5
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Personally I just store the full path to the file, unless of course all images are in a single folder - then use Linq's example
    Code:
    Folder & "\FileName.ext"
    George
    Home | Blog

  6. #6
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    I think (I could be wrong; I have been three times, as I tell my 4th wife) that the OP wants to be able to store the images in the same folder that the db resides in, and reference it, regardless of where the user has installed the db.

    God, was that right? I've been on pain medication for three days now!

    Linq
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  7. #7
    Join Date
    Aug 2007
    Location
    Ireland
    Posts
    13
    Hi Linq & georgev,
    I am following the test & code as described in http://support.microsoft.com/kb/148463 ( ACC: How to Display Images in a Form or in a Report Without Storing the Images in a Table ).

    This is working fine for me but it is not relative addressing. I have tried putting CurrentProject.Path & "\person1.jpg" (I am using the correct filename) in the field ImagePath but I loose all the images until I revert back to the actual directory listing.

    What am I missing?

    And BTW, Linq, with one wife and four teenagers I am always wrong, yep always

    Zedekiah.

  8. #8
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    What method are you using to show your pictures? My preference is VBA, in which I use
    Code:
    Me.Image1.Picture = CurrentProject.Path & "\Image1.jpg"
    George
    Home | Blog

  9. #9
    Join Date
    Aug 2007
    Location
    Ireland
    Posts
    13
    Hi georgev,
    I am using the following code
    Me![ImageFrame].Picture = Me![ImagePath]

    This implies that there is a field name called ImagePath in the table bound to the form. ImageFrame is the name of the control (for the image). So in order to display Me![ImageFrame].Picture MSAccess goes off to the relevant cell Me![ImagePath] and displays the image.

    In your code example above I should put this into the Code window where now I have Me![ImageFrame].Picture = Me![ImagePath]
    I should put
    Me.Image1.Picture = CurrentProject.Path & "\Image1.jpg" Is this correct? Or could I put
    Me.Image1.Picture = CurrentProject.Path & [ImagePath]. I will try this and let you know how I get on. But I value any insights that you offer.


    Okay a number of things.

    You have Me.Image1.Picture whereas MS have Me![ImageFrame].Picture. I appreciate that Image 1 & ImageFrame are one and the same - they reference the control in the form. What about the Me. & Me! What is the difference here?

    Should there also be Me!CurrentProject.Path & "\Image1.jpg" or Me.CurrentProject.Path & "\Image1.jpg"

    Does the code above just reference the image in the directory/folder directly. MS code actually gets the address of the image from the address stored in the field cell called ImagePath in this instance.

    I will go off and try some of the ideas that this discussion has generated and see how I get on.

    Slowly going mad...

    Zedekiah.

  10. #10
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926

    Opening files Menu system

    Here's something I've used to store links to any file types (including jpg's) and open them via an MSAccess "menu". You may find some part of it useful (ie. "Opening a Program" Module.) It shows 2 different ways you can open a saved link to a file (ie. instead of opening the picture up in a ole object on a form, it opens the picture up using MSPaint or whatever program you specify to open up the picture file.)

    I hope it helps in some way.
    Attached Files Attached Files
    Last edited by pkstormy; 08-21-07 at 08:39.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  11. #11
    Join Date
    Aug 2007
    Location
    Ireland
    Posts
    13
    Hi,
    I have just returned from holidays. I will go though what has been suggested and get back with response.

    Zedekiah.

  12. #12
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    There are various mechanisms to retrieve files form a file system
    you can use an absolute drive ID eg "C:\documents and settings\<myuserid>\my photos"
    ..that works providing that any instance of access always uses the same drive ID to indicate the physical location of the file. say you had a the photos on a networked drive and every workstation that needed to use the photos knew that drive as "Z:", it wont work if you use "C:"

    a better solution is to use the UNC convention which allows you to specify a server, this is soemthing like \\<myservername\<my path>

    alterntaively you could use a full URL eg http://<myservername/<path to image>

    bear in mind that a UNC or URL needn't be the actual physical addrerss int he disks fiel structure, but may actually be a compacted form of the file structure or even called something different. for example int he windows world its possible to define a shared area (directory) of a server disk and call it something else.

    if you are merely concerned with where to stroe your images on a non networked standalone application then ideally you should give the full physical path, or retrieve the path say from the ENVIRON settings. Note if you hardcode the path to a physical location then should you move the data then
    the app will fail. thats why Id always suggest using a relative mechanism. Currentproject tells you where the access application is located, and that may well be appropriate for most uses.

    this bit from wiki may help
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

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