I am building a catalog database for a photo archive. My Photos table contains records which have information about photos that are stored as .jpg files in a known directory. Each time a photo is captured as a .jpg file, say 123.jpg, the user creates a record in the Photos table and stores information about that photo in the record. In the Filename field of the record, the user provides the filename of the .jpg file.
When the record is displayed in a CONTINUOUS form or report, I want to display the image of the .jpg file for each record displayed, but I do NOT want to store that image in the database in order to keep the database small in size. I thought I had a solution by adding an unbound OLE control to the form and when the user input the filename to the Filename field I would execute the following code to link the .jpg image to the unbound control as an OLE link, NOT an embedded object. Well, the images appeared fine in the form, but I noticed that the database grew on the order of 2 MB or so for each photo that was LINKED (even though the .jpg file itself was under 500KB).
Can anyone tell me what kind of control I should be using on the form or report and how I can LINK it to the .jpg image file so it displays properly on the form / report and not use up a lot of memory in the database?
NOTE: I have seen other FAQs and threads that tell you to link an image control to the file, but that does not work on a continuous form where you want one image for one record and another image for the next record, etc. When I tried the image control, I got the same picture to show on all records displayed.
Here is the code that I use to link the image to the control when the user enters the filename. The control has the OLE Type Allowed property set to "Linked"
Private Sub Filename_AfterUpdate()
On Error GoTo Err_Filename_AfterUpdate
Dim Root As String
Root = Filename.Value
' not required any more Root = Left(Root, Len(Root) - 5) ' Strip off the ".TIFF" end
Root = "C:\RHSPhotos\jpg\" & Root & ".jpg"
Photo.Value = Root
OLEBoundPhoto.SourceDoc = Root
OLEBoundPhoto.Action = acOLECreateLink
'CDID.SetFocus
Exit_Filename_AfterUpdate:
Exit Sub
Err_Filename_AfterUpdate:
Select Case Err.Number
Case 2101 ' File cannot be found?
MsgBox "A photo file by that name could not be found."
Resume Next
Case Else
MsgBox "Error # " & Err.Number & " " & Err.Description
End Select
Resume Exit_Filename_AfterUpdate
End Sub
When the record is displayed in a CONTINUOUS form or report, I want to display the image of the .jpg file for each record displayed, but I do NOT want to store that image in the database in order to keep the database small in size. I thought I had a solution by adding an unbound OLE control to the form and when the user input the filename to the Filename field I would execute the following code to link the .jpg image to the unbound control as an OLE link, NOT an embedded object. Well, the images appeared fine in the form, but I noticed that the database grew on the order of 2 MB or so for each photo that was LINKED (even though the .jpg file itself was under 500KB).
Can anyone tell me what kind of control I should be using on the form or report and how I can LINK it to the .jpg image file so it displays properly on the form / report and not use up a lot of memory in the database?
NOTE: I have seen other FAQs and threads that tell you to link an image control to the file, but that does not work on a continuous form where you want one image for one record and another image for the next record, etc. When I tried the image control, I got the same picture to show on all records displayed.
Here is the code that I use to link the image to the control when the user enters the filename. The control has the OLE Type Allowed property set to "Linked"
Private Sub Filename_AfterUpdate()
On Error GoTo Err_Filename_AfterUpdate
Dim Root As String
Root = Filename.Value
' not required any more Root = Left(Root, Len(Root) - 5) ' Strip off the ".TIFF" end
Root = "C:\RHSPhotos\jpg\" & Root & ".jpg"
Photo.Value = Root
OLEBoundPhoto.SourceDoc = Root
OLEBoundPhoto.Action = acOLECreateLink
'CDID.SetFocus
Exit_Filename_AfterUpdate:
Exit Sub
Err_Filename_AfterUpdate:
Select Case Err.Number
Case 2101 ' File cannot be found?
MsgBox "A photo file by that name could not be found."
Resume Next
Case Else
MsgBox "Error # " & Err.Number & " " & Err.Description
End Select
Resume Exit_Filename_AfterUpdate
End Sub