Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2004
    Posts
    4

    Unanswered: Display Images in a Form Without Storing the Images in a Table

    I've tried using the vb code on the Microsoft web site (http://support.microsoft.com/default...=acc#appliesto) to display an image in an unbound field within a form. This way I do not have to store the image in a table, taking up space. I have been unsuccessful, however. Has anyone had similar problems or advice?

  2. #2
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    That seemed like an awful lot more work then is necessary to link to a picture via path...
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  3. #3
    Join Date
    Feb 2004
    Posts
    533
    This works pretty good. In the Form Design view add an 'Image' Object to the form. Follow the wizard to set an image to a default "Default.jpg" (You can make a jpg that says blank for records that do not have an image.) Then use the On Current Event of the Form to add code to set the Picture Path based on the 'ClientID' or 'ImageName' value of the record which identifies the related image located in a specified path.

    The code should be something like this only referring to the imagename field on your form and using the correct image path constant for your photos directory. Set image Format properties as 'Linked' and 'Zoom' or 'Clip'. If using 'Clip' make sure you size images to exactly fit the image frame on your form.

    Code:
    Option Compare Database
    
    Const strDefPath = "C:\Database Location\DBImageFiles\"
    
    Private Sub Form_Current()
     Dim strPhotoPath As String
      
     strCurImg = Me.ImageName
     strPhotoPath = strDefPath & strCurImg & ".jpg"
     
    If Not fIsFileDIR(strPhotoPath) Then
        strPhotoPath = strPath & "Default.jpg"
    End If
    
     
     Me.imgField.Picture = strPhotoPath
    End Sub
    
    
    '
    'Function Code Courtesy of
    'Dev Ashish
    'Ref. http://www.mvps.org/access/modules/mdl0009.htm
    '
    Function fIsFileDIR(stPath As String, _
                        Optional lngType As Long) _
                        As Integer
    
        On Error Resume Next
        fIsFileDIR = Len(Dir(stPath, lngType)) > 0
    End Function
    Last edited by savbill; 08-17-04 at 22:01.
    ~

    Bill

Posting Permissions

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