Results 1 to 7 of 7
  1. #1
    Join Date
    May 2004
    Posts
    80

    Unanswered: Image paths within same folder?

    Hello, I'd like to insert a linked image into my form header. Trouble is, it alternates between drives - the source file for both the image and the database are within my USB device, but I use it at home and school. At home, it is allocated the I: and at school it is the E:. Therefore each time I switch between home and school (daily) I get error messages saying "E:....." cannot be found (when at home) and vice versa with the I: at school. Is there a way to define the image source so that it comes from within the same folder as the database file, rather than a full address? This kind of thing can be done in HTML, with which I am very familiar, but I'm starting to wonder if Access will have the same capabilities. I need this to work because our databases have to be submitted to external assessors at the end of the year, and I can't have the images broken or else I'll not get a very good grade.

    I tried simply changing the path to "image.gif" (to denote the same folder) but it immediately reverted back to the full path.

    Thanks,

    Grace

  2. #2
    Join Date
    Jan 2002
    Location
    At the Edge of America!
    Posts
    55
    I would suggest that you have a form when the database opens to select if your at home or school.

    Or use this when your database starts or have a button to select.

    file opens to select the drive.

    http://www.mvps.org/access/api/api0001.htm

    Once you do this then store the information in a public varible or in a data table. Call the path anytime you need it.

    Pretty simple. I use this anytime I create a database for linking data tables.

  3. #3
    Join Date
    Jan 2002
    Location
    At the Edge of America!
    Posts
    55
    Here is another link that might help you.

    http://www.mvps.org/access/api/api0003.htm

  4. #4
    Join Date
    Feb 2004
    Location
    Canada
    Posts
    133
    I've used the following function to retrieve the current path.

    Function pathname() As String
    'find the path of the current database

    Set db = CurrentDb
    filename = db.Name
    pathname = Mid(filename, 1, Len(filename) - Len(Dir(filename)))

    End Function

    I just concatenate an image filename to the end and use it to change the picture property of an image control.
    e.g.
    Me.ImageCtrl.Picture = pathname & "\Image.jpg"

  5. #5
    Join Date
    May 2004
    Posts
    90
    This was not even my question but I was having the same issue. That code worked great! Thanks

  6. #6
    Join Date
    May 2004
    Posts
    90
    I was wondering though, do you think this code will work with users running the database over a network? Is it going to look up the path on network drive (hopefully)? Or on the remote user's drive?

  7. #7
    Join Date
    Jun 2004
    Location
    Florida, US
    Posts
    521
    You can also use;
    a. Application.CurrentProject.Path property to get database path
    b. Application.CurrentProject.Name property to get database name.
    c. Application.CurrentProject.FullName property to get full path and name.

    In this case CurrentProject.Path property what you are looking for I guess.
    Last edited by ghozy; 06-04-04 at 12:52.

Posting Permissions

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