Memory issues displaying linked images in reports (1 Viewer)

ledgerr.rob

Registered User.
Local time
Today, 04:36
Joined
Jun 3, 2012
Messages
68
Access 2007
Windows Vista
GOAL: Display linked images in image control, and to ultimately to export reports to pdf to share with family by email or to print
ERROR: “There isn’t enough free memory to update the display. Close unneeded programs and try again.”

I’ve created a DB for family heirlooms and as part of this I’ve included images. I’ve done this by storing the filename of the picture as text in the table tblPicture with a one to many relationship to the tblItem. This allows for many pictures of the item itself. I wanted to be able to show the most represent able photo of each item and added a checkbox titled ‘primary picture’ to the tblPicture. I use this value in the query’s to filter out all but one image per record.

During my initial design and testing (20 or so items) I was having no problems. I’ve added around 450 items to date, many of which have multiple pictures. I have started to run into some memory trouble now when running a few query driven reports.

As many on the forum have suggested previously I have stored only the file name in a text field in a table of the DB. I store all of my images in an ‘images’ folder that is relative and constant to the DB location. I use code to display the images on the form with no problems (yet).

For displaying images on my reports,
1. I check to see if the record has an image path stored
2. If not I set the image control on the report to nothing
3. If there is a relative path stored I collect the DB path, and add the relative path and set the image control to that concatenated path

(Looking at my set up now I can tell I should only get the db path once at the beginning instead of for each record…I’ll fix that.)

Code:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    Dim strDBPath As String
    Dim strRelativePath As String
    Dim strPath As String
    
    'Test to see if the record has a relative path stored
    If IsNull(Me!Picture) Then
        'If it does not (null) turn the picture value to nothing
        Me.imgControl1.Picture = ""
    Else
        'If it does (not null) then turn the picture value to the full path
        'store the relative path
        strRelativePath = Me!Picture.Text
        
        'store the path of the database
        strDBPath = CurrentProject.path
        
        'concatenate the DB path, the images folder, and the relative path and store to strPath
        strPath = strDBPath & "\Images\" & strRelativePath
        
        'set the picture value to strPath
        Me!imgControl1.Picture = strPath
        
    End If
    
End Sub

Lastly, I have a few different pre-built reports that generate any number of records. For instance, I can select by the original owner of the item. If that person has only a few items to their name I have no problems. But if that person has let’s say 100 or more I get the error.

I guess my question is how can I set up my report to display my reports with images to avoid the lack of memory. Is using the image control and setting the picture property in code wrong? (obviously since it’s not working lol). Maybe not using an if loop would be better?

I appreciate any tips on this issue.
Rob
 

SOS

Registered Lunatic
Local time
Today, 04:36
Joined
Aug 27, 2008
Messages
3,517
See if keeping the picture's resolution to 1024x768 will help. I've heard that can help with something of this nature.
 

Users who are viewing this thread

Top Bottom