Solved

Can't Display Image File in Access Runtime on Some Windows 7 Systems

Posted on 2011-03-07
13
419 Views
Last Modified: 2012-05-11
I have an Access 97 runtine application with about 800 users.  (I know it's ancient ... I am currently re-writing / updating it, but that will take a few more months.)

One feature allows users to link to pictures in the database. The data table doesn't store the actual picture object; it stores the path to the picture (stored on the user's hard drive). The UI form allows the user to view the picture(s) and print as well.

This works as desired for the majority of users, but a handful of users with Windows 7 machines can't use this feature. When they try to add a picture, they get an error that the application doesn't support the file format, even though they are working with the standard JPG, GIF, or BMP formats.

To be clear, this is only happening to a few Win7 users. Many other Win7 users have no issue with the picture feature. I have two Win7 machines here and it works great on both, which of course makes it difficult for me to troubleshoot an issue that I can't reproduce.

I had a similar issue with this same application a number of years ago with Windows XP ... most users had no problem but a few received the "doesn't support this format" error. I was able to resolve that by creating a quick exe patch that set the Windows graphics filters on their machines ... they would run that once and then all would be fine.  Running that exe patch on the Win 7 machines has not resolved the issue, and I haven't turned up any helpful research on graphics filters in Win 7.

I worked with one user that was experiencing this issue and I remotely accessed his PC and compared relevant registry keys to those in my Win7 machine and found no differences.

I'm including the code for the UI form here; the first sub is used to display the picture and the second sub allows the user to browse for a picture file and then stores the path to that picture in the table.  

I would appreciate any suggestions to resolve this - whether it involves changing the code or something else that the user needs to do.  

Thanks in advance for any advice!
Private Sub Form_Current()
    On Error Resume Next
    If IsNull(Me.PicPath) = False Then
        Me.imgPic.Picture = Me.PicPath
    Else
        Me.imgPic.Picture = ""
    End If    
    Me.Refresh
End Sub

Private Sub btnAdd_Click()
    Dim theFlags As Long
    Dim strFilter As String
    Dim strFile As String
    Dim strPath As String
    Dim resp As Variant
    Dim i As Integer
    Dim rs As Recordset
    Dim db As Database
    Dim bkmark As Variant
    
    If Me.Dirty = True Then Me.Dirty = False
    
    If IsNull(Me.PicPath) = False Then
        resp = DisplayMessage(138)  'ask if they want to replace existing pic or add another pic record
        
        If resp = vbCancel Then GoTo Exit_btnAdd_Click        'don't add a new pic
        'get path of current file
        strPath = Me.PicPath
        For i = 1 To Len(strPath)
            If Right(strPath, 1) = "\" Then    'file name has been removed, only path is left
                Exit For
            Else
                strPath = Left(strPath, Len(strPath) - 1)
            End If
        Next i
    Else
        strPath = "C:\"                 'default directory
    End If
    
'get path and file name for picture.
    theFlags = ahtOFN_FILEMUSTEXIST + ahtOFN_HIDEREADONLY _
        + ahtOFN_NODEREFERENCELINKS + ahtOFN_LONGNAMES
    strFilter = ahtAddFilterItem(strFilter, "Graphic Files", "*.bmp;*.jpg;*.tif;*.wmf")
    strFile = ahtCommonFileOpenSave(theFlags, InitialDir:=strPath, Filter:=strFilter, _
        DialogTitle:="Location and Name of Picture", OpenFile:=False)
        
    If strFile = "" Then GoTo Exit_btnAdd_Click       'user cancelled dialog
    
    'make sure there is a parent record
    With Forms!HorseNotes
        If IsNull(!NoteID) = True Then
            If .NewRecord = True And .Dirty = False Then
                !Note = "[picture(s) included]"
                .Dirty = False      'save new note
            End If
        End If
    End With
        
    If resp = vbNo Then                     'add selected pic to a new record
        Set db = CurrentDb
        Set rs = Me.RecordsetClone
        With rs
            .AddNew
            !NoteID = Me.Parent!NoteID
            !PicPath = strFile
            .Update
            bkmark = .LastModified
            Me.Bookmark = bkmark        'move to new record
        End With
    Else
        Me.PicPath = strFile
    End If
    
    Call Form_Current
    
Exit_btnAdd_Click:
On Error Resume Next
    If Not (rs Is Nothing) Then rs.Close: Set rs = Nothing
    If Not (db Is Nothing) Then db.Close: Set db = Nothing
Exit Sub
End Sub

Open in new window

Private Sub Form_Current()
    On Error Resume Next
    If IsNull(Me.PicPath) = False Then
        Me.imgPic.Picture = Me.PicPath
    Else
        Me.imgPic.Picture = ""
    End If    
    Me.Refresh
End Sub

Private Sub btnAdd_Click()
    Dim theFlags As Long
    Dim strFilter As String
    Dim strFile As String
    Dim strPath As String
    Dim resp As Variant
    Dim i As Integer
    Dim rs As Recordset
    Dim db As Database
    Dim bkmark As Variant
    
    If Me.Dirty = True Then Me.Dirty = False
    
    If IsNull(Me.PicPath) = False Then
        resp = DisplayMessage(138)  'ask if they want to replace existing pic or add another pic record
        
        If resp = vbCancel Then GoTo Exit_btnAdd_Click        'don't add a new pic
        'get path of current file
        strPath = Me.PicPath
        For i = 1 To Len(strPath)
            If Right(strPath, 1) = "\" Then    'file name has been removed, only path is left
                Exit For
            Else
                strPath = Left(strPath, Len(strPath) - 1)
            End If
        Next i
    Else
        strPath = "C:\"                 'default directory
    End If
    
'get path and file name for picture.
    theFlags = ahtOFN_FILEMUSTEXIST + ahtOFN_HIDEREADONLY _
        + ahtOFN_NODEREFERENCELINKS + ahtOFN_LONGNAMES
    strFilter = ahtAddFilterItem(strFilter, "Graphic Files", "*.bmp;*.jpg;*.tif;*.wmf")
    strFile = ahtCommonFileOpenSave(theFlags, InitialDir:=strPath, Filter:=strFilter, _
        DialogTitle:="Location and Name of Picture", OpenFile:=False)
        
    If strFile = "" Then GoTo Exit_btnAdd_Click       'user cancelled dialog
    
    'make sure there is a parent record
    With Forms!HorseNotes
        If IsNull(!NoteID) = True Then
            If .NewRecord = True And .Dirty = False Then
                !Note = "[picture(s) included]"
                .Dirty = False      'save new note
            End If
        End If
    End With
        
    If resp = vbNo Then                     'add selected pic to a new record
        Set db = CurrentDb
        Set rs = Me.RecordsetClone
        With rs
            .AddNew
            !NoteID = Me.Parent!NoteID
            !PicPath = strFile
            .Update
            bkmark = .LastModified
            Me.Bookmark = bkmark        'move to new record
        End With
    Else
        Me.PicPath = strFile
    End If
    
    Call Form_Current
    
Exit_btnAdd_Click:
On Error Resume Next
    If Not (rs Is Nothing) Then rs.Close: Set rs = Nothing
    If Not (db Is Nothing) Then db.Close: Set db = Nothing
Exit Sub
End Sub

Open in new window

0
Comment
Question by:JMS1965
  • 8
  • 3
  • 2
13 Comments
 
LVL 38

Assisted Solution

by:puppydogbuddy
puppydogbuddy earned 500 total points
Comment Utility
If the following security update has been applied to the machines in question, that is what started the problems.  Microsoft subsequently issued a patch for Win 7 that did not work.  The last link below contains the following info in relation to a fix:

There’s a known problem with the Office Graphics Filters patch, MS10-105 / KB 968095. The patch intentionally disables some graphics filters, making it impossible to view or import certain kinds of image files into your Office docs. There’s more information about the filters that have been disabled, and how to edit the Registry to enable them if you really, really want to, in KB 2479871.

http://www.microsoft.com/technet/security/bulletin/ms10-105.mspx

http://windows7forums.com/security-alerts/54625-ms10-105-important-vulnerabilities-microsoft-office-graphics-filters-could-allow-remote-code-execution-968095-version-1-0-a.html

http://www.askwoody.com/tag/office-graphics-filters/
0
 

Author Comment

by:JMS1965
Comment Utility
Hi puppydogbuddy -

Looks like you have provided great info here ... I'll look into this later today and get back to you.

Thank you!
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
Comment Utility
Just some notes...

As a general rule, I don't "Call" the current event. (like you are doing in your button click code)
I let it trigger on its own.
If you need this "Image code", then put it in its own sub and Call it from the current event.

This is because the current event can also contain other code that you may not want to run, if you only need to display an image.

Then in your Button _Click code I would call this new sub, (not the Current Event)

Something like this:

Private Sub DisplayImage()
    On Error Resume Next
    If IsNull(Me.PicPath) = False Then
        Me.imgPic.Picture = Me.PicPath
    Else
        Me.imgPic.Picture = ""
    End If    
    Me.Refresh
End sub


Private Sub Form_Current()
    'Some other code
    Call DisplayImage
    'Some other code
End Sub

Private Sub btnAdd_Click()
    Dim theFlags As Long
    Dim strFilter As String
    Dim strFile As String
    Dim strPath As String
    Dim resp As Variant
    Dim i As Integer
    Dim rs As Recordset
    Dim db As Database
    Dim bkmark As Variant
   
    If Me.Dirty = True Then Me.Dirty = False
   
    If IsNull(Me.PicPath) = False Then
        resp = DisplayMessage(138)  'ask if they want to replace existing pic or add another pic record
       
        If resp = vbCancel Then GoTo Exit_btnAdd_Click        'don't add a new pic
        'get path of current file
        strPath = Me.PicPath
        For i = 1 To Len(strPath)
            If Right(strPath, 1) = "\" Then    'file name has been removed, only path is left
                Exit For
            Else
                strPath = Left(strPath, Len(strPath) - 1)
            End If
        Next i
    Else
        strPath = "C:\"                 'default directory
    End If
   
'get path and file name for picture.
    theFlags = ahtOFN_FILEMUSTEXIST + ahtOFN_HIDEREADONLY _
        + ahtOFN_NODEREFERENCELINKS + ahtOFN_LONGNAMES
    strFilter = ahtAddFilterItem(strFilter, "Graphic Files", "*.bmp;*.jpg;*.tif;*.wmf")
    strFile = ahtCommonFileOpenSave(theFlags, InitialDir:=strPath, Filter:=strFilter, _
        DialogTitle:="Location and Name of Picture", OpenFile:=False)
       
    If strFile = "" Then GoTo Exit_btnAdd_Click       'user cancelled dialog
   
    'make sure there is a parent record
    With Forms!HorseNotes
        If IsNull(!NoteID) = True Then
            If .NewRecord = True And .Dirty = False Then
                !Note = "[picture(s) included]"
                .Dirty = False      'save new note
            End If
        End If
    End With
       
    If resp = vbNo Then                     'add selected pic to a new record
        Set db = CurrentDb
        Set rs = Me.RecordsetClone
        With rs
            .AddNew
            !NoteID = Me.Parent!NoteID
            !PicPath = strFile
            .Update
            bkmark = .LastModified
            Me.Bookmark = bkmark        'move to new record
        End With
    Else
        Me.PicPath = strFile
    End If
   
    Call DisplayImage
   
Exit_btnAdd_Click:
On Error Resume Next
    If Not (rs Is Nothing) Then rs.Close: Set rs = Nothing
    If Not (db Is Nothing) Then db.Close: Set db = Nothing
Exit Sub
End Sub
0
 

Author Comment

by:JMS1965
Comment Utility
Boaq2000 -

Makes sense ... thanks for the tip! I'll make the recommended change.
0
 

Author Comment

by:JMS1965
Comment Utility
puppydogbuddy -

Thanks again for the info. I have read the material / links you provided and it sure seems to be related to the issue some of my customers are having.

However, I'm a bit confused with the "Microsoft-speak" in the KB articles.  Just to clarify ... is the security patch causing the problem, or is it intended to resolve the problem?

If it is causing the problem, are they then saying that users have to manually edit their registry keys (thus creating a security hole) in order to use graphic files in Office programs? Yikes!

Sorry to bug you, but I just want to make sure I understand this before making my customers (who are very basic PC-users, not experts at all) jump through hoops so we can test this.

Thanks!
0
 
LVL 38

Expert Comment

by:puppydogbuddy
Comment Utility
Microsoft's patch disabled the graphics filters to alleviate a threat to Windows OS security (malicious code could be delivered behind an image).  Thus the patch created the problem you are having.

Yes, changing the registry keys would have to be done on each machine having the problem.  However, there are scripts that will automate the changes to the registry keys.  Try googling on "VB code to change the windows registry keys".
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 

Author Comment

by:JMS1965
Comment Utility
Sorry for the delay in updating this. I have had a hard time reaching any customers who have this issue in order to try to resolve it using the information you provided.  I'll keep trying and will post an update in the next few days.

Thanks!
0
 

Author Comment

by:JMS1965
Comment Utility
Hello -

I have an update on this issue, which unfortunately is not resolved. I've connected with two customers who are experiencing the problem, and it seems the MS Security Patch referenced above is not the cause. Both of them had the problem before December, when the patch was released.

Does any one have any other suggestions?

Thanks!
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
Comment Utility
Not sure.

There are quite a few questions here on "issues" with Win 7
0
 

Accepted Solution

by:
JMS1965 earned 0 total points
Comment Utility
Puppydogbuddy and boaq2000 -

Thanks very much for trying to help here. This elusive problem is really driving me crazy! I will do some more research and then may re-post a new question on e-e, perhaps more targeted to "if I can get access to two Win 7 machines, 1 which handles image files and 1 which doesn't, what specifically should I compare to try to pin down this issue?"

If you have any other suggestions (either for a solution or for re-framing a new question), please let me know.

I wish I could find a way to just have the affected users re-install the Office graphic filters, but I haven't found anything helpful on that either.

I'll leave this question open for a couple days in case you have anything to add, then will close and award points.  Thanks again!
0
 
LVL 38

Expert Comment

by:puppydogbuddy
Comment Utility
see the link below for Microsoft's coded function to display images.  You should compare and test your code against the code provided by Microsoft and see if works.

http://support.microsoft.com/kb/285820
0
 

Author Comment

by:JMS1965
Comment Utility
Hi puppydogbuddy -

I reviewed the KB article you referenced. Although I don't use a separate function as is shown in the article, I am using the same assignment method to display the image:

ControlName.Picture = FilePathFileName

Thanks anyway ...
0
 

Author Closing Comment

by:JMS1965
Comment Utility
Thanks for trying to help -- I so appreciate your efforts. Unfortunately this is unresolved; I will try to re-frame a new question. This issue is making me crazy!
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
OfficeMate Freezes on login or does not load after login credentials are input.
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now