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?
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.
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"
Me.imgField.Picture = strPhotoPath
'Function Code Courtesy of
Function fIsFileDIR(stPath As String, _
Optional lngType As Long) _
On Error Resume Next
fIsFileDIR = Len(Dir(stPath, lngType)) > 0