Home  |  About  |   Search   

What's New
Table Of Contents
Credits
Netiquette
10 Commandments 
Bugs
Tables
Queries
Forms
Reports
Modules
APIs
Strings
Date/Time
General
Downloads
Resources
Search
Feedback
mvps.org

RunCommand Constants

Terms of Use


 

Bugs: Image Control may cause a GPF when browsing between records

Author(s)
Dev Ashish
  Generally, the practice of storing images in Access tables  isn't recommended due to the reasons outlined in the article "Handle/Display images in forms/databases". A workaround is to store the path to the image in a text field instead and assign it to an image control's Picture property at runtime by using code similar to the following snippet: (ImagePath is the name of the field containing the filename and path of the images)
'********* Code Start *********
Private Sub Form_Current()
    With Me
        ' Assign new image path to the
        ' image control's Picture property
        .imgImageDisplay.Picture = .ImagePath
    End With
End Sub
'********* Code End *********

However, if the image files are moderately large, and if the user tries to quickly navigate to different records by using the built in navigation buttons before the "Loading Image" asynchronous dialog closes, the result is either a General Protection Fault  in Access, or the message "Out Of Stack Space" before Access terminates.

A workaround is to disable the built-in navigation buttons before assigning a new filename to the Image control's Picture property.  If you are using custom Navigation buttons on your forms, you will have to temporarily disable them in the same fashion.

'********* Code Start *********
Private Sub Form_Current()
    With Me
        ' Hide the built-in navigation buttons
        .NavigationButtons = False
        
        ' Assign new image path to the
        ' image control's Picture property
        .imgImageDisplay.Picture = .ImagePath
        
        ' Turn the built-in navigation buttons back on
        .NavigationButtons = True
    End With
End Sub
'********** Code End **********

1998-2009, Dev Ashish & Arvin Meyer, All rights reserved. Optimized for Microsoft Internet Explorer