Relative path & image

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ruymán

    #1

    Relative path & image

    Hello!,

    is possible use relative path in access? for example use "photo\image1.j pg"
    instead of "c:\db\photo\im age1.jpg", I try it but I cann't, but in Visual
    Basic if is possible.

    Other question but relationated, Is posible don´t put a path to the picture
    in the image control (in desing) ?

    The Database will be move frecuntly and it will give error in the form load
    because the path to the image change, for this I'm making these questions.
    After of load of the form I load the pictures for code using
    currentproject. path and I don´t have problem with this.

    I thought that to capture the error would be the solution, but the error
    message is produced it before of the load form event.

    Thanks a lot.


  • Gord

    #2
    Re: Relative path & image

    >is possible use relative path in access? for example use "photo\image1.j pg"
    >[...]
    >I thought that to capture the error would be the solution, but the
    >error message is produced it before of the load form event.
    Yes, that seems to be the case with the Image control. You might have
    better luck with an Unbound OLE Object control that is linked to the
    original location of the image when the control is added. I tried that,
    and the following works for me when I move the files to a new location:


    Private Sub Form_Load()
    Dim strDbPath As String

    ' get current database filespec...
    strDbPath = CurrentDb.Name
    ' ...and just take the path
    strDbPath = Left(strDbPath, InStrRev(strDbP ath, "\", , vbTextCompare))

    ' set the image location
    Me.OLEUnbound1. SourceDoc = strDbPath & "MyImage.jp g"

    End Sub



    Ruymán wrote:
    Hello!,
    >
    is possible use relative path in access? for example use "photo\image1.j pg"
    instead of "c:\db\photo\im age1.jpg", I try it but I cann't, but in Visual
    Basic if is possible.
    >
    Other question but relationated, Is posible don´t put a path to the picture
    in the image control (in desing) ?
    >
    The Database will be move frecuntly and it will give error in the form load
    because the path to the image change, for this I'm making these questions.
    After of load of the form I load the pictures for code using
    currentproject. path and I don´t have problem with this.
    >
    I thought that to capture the error would be the solution, but the error
    message is produced it before of the load form event.

    Thanks a lot.

    Comment

    • Jamey Shuemaker

      #3
      Re: Relative path & image

      You could set the Image's Picture property in the Load event using:

      Me!MyImage.Pict ure = CurrentProject. Path & strImage

      Where strImage = "\ImageName.ico "

      Or you could just set the PictureType property to Embedded. If this
      setting is used, it won't matter where you move the database, so long
      as the image itself does not depend on user input or other dynamic
      events.

      Comment

      Working...