Displaying Images

R

Ray

I am running Access 2003. I used the methods described at
http://support.microsoft.com/kb/285820/ to display images bound to records in
my database, and it worked beautifully until I changed one of my computers
from Windows 2000 to Windows XP, and now I get an error (-2147417848 Method
picture of object_image failed), and it will not load my pictures. It works
fine on my other computers that still run Windows 2000, but it won't work on
those that run XP.

Any ideas?
 
T

Tom Wickerath

Hi Ray,

Perhaps there is something helpful for you in this KB article:

INFO: Error or Unexpected Behavior with Office Automation
When You Use Early Binding in Visual Basic
http://support.microsoft.com/kb/319832

Have you checked for any references marked as MISSING, and verified that
your code compiles without any errors on the affected PCs?

Solving Problems with Library References (Allen Browne)
http://allenbrowne.com/ser-38.html

Access Reference Problems (Doug Steele)
http://www.accessmvp.com/djsteele/AccessReferenceErrors.html

Can you try my ImageDemo sample and see if it fails as well? Note: This is a
work-in-progress, which is not finished yet, but it does work correctly on
WindowsXP with Access 2003:

http://home.comcast.net/~tutorme2/samples/ImageDemo.zip

If my sample is also failing on these PCs, then I suspect that you may have
one or more libraries that are not registered correctly.


Tom Wickerath
Microsoft Access MVP
https://mvp.support.microsoft.com/profile/Tom
http://www.access.qbuilt.com/html/expert_contributors.html
__________________________________________
 
R

Ray

Thanks for responding,

Your image demo worked fine on my 2000 computer, but not on the XP. On XP,
it doesn't give the same error, but rather it just says "picture not found."
I looked at the references and couldn't find anything missing or out of date.
As far as I can tell, article 319832 doesn't apply because it doesn't work
at all, even once, but I think perhaps I am in a bit over my head here.
 
T

Tom Wickerath

Hi Ray,

The code in the frmEmployees form, in my ImageDemo sample, came from a copy
of Northwind. The "picture not found" response that you see is from code in
this form's Current event procedure. It turns out that this code includes On
Error Resume Next, so it is not going to result in an error number or message
similar to what you are seeing with your database being displayed.

I'd like you to try an experiment using my ImageDemo sample on the Windows
XP machine. First, open the tblEmployees table in normal view, and scroll
horizontally until you see the field named "Photo". For Employee ID 5, Steven
Buchanan, and for Employee ID 8, Laura Callahan, enter valid paths to two
images saved in some folder on your hard drive. For example:

C:\Temp\Picture1.jpg and
C:\Temp\Picture2.jpg

(I'm having you enter paths to valid pictures for these two people, since
the form's recordset is ordered ascending by lastname, and firstname--these
are the first two records that you should see).

Then open the frmEmployees form in design view. Then click on View > Code.
Scroll down to where you should see the Current event procedure for this form:

Private Sub Form_Current()

Add some Debug.Print statements, as indicated below:

Me![ImageFrame].Picture = fName
ShowImageFrame
Me.PaintPalette = Me![ImageFrame].ObjectPalette

Debug.Print "Me.PaintPalette: " & Me.PaintPalette
Debug.Print "[ImageFrame].Picture: " & Me![ImageFrame].Picture
Debug.Print "fName: " & fName
Debug.Print

If (Me![ImageFrame].Picture <> fName) Then
HideImageFrame
errormsg.Caption = "Picture not found"
errormsg.Visible = True
End If

Minimize the code window. Reopen the form in normal mode, and then use the
navigation button to move to record # 2 for Laura Callahan. Then tap <Ctrl>
<G> (the Control and G keys, at the same time) to open the Immediate window.
You should see something like the following:

Me.PaintPalette: `A @ ` ? À à † ? ? 0 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
?[ImageFrame].Picture: C:\Temp\Picture1.jpg
fName: C:\Temp\Picture1.jpg

Me.PaintPalette: `A @ ` ? À à † ? ? 0 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
[ImageFrame].Picture: C:\Temp\Picture2.jpg
fName: C:\Temp\Picture2.jpg

The first line for each image will be a bunch of weird characters (I'm not
showing the entire contents of the first line). The point is that *something*
similar should be printed to the Immediate Window for Me.PaintPalette. I'm
thinking that something is interferring with the ObjectPalette property on
your system. Here is some information that I copied from the Access 2003 Help
system, when I selected the word ObjectPalette in the Current event
procedure, and pressed the F1 button to bring up context-sensitive Help:

If the application associated with the OLE object, bitmap, or other graphic
doesn't have an associated palette, the ObjectPalette property is set to an
zero-length string.

The setting of the ObjectPalette property makes the palette of the
application associated with the OLE object, bitmap, or other graphic
contained in a control available to the PaintPalette property of a form or
report.
=====================================

Experiment # 2:
Please navigate to Access MVP Stephen Leban's page here:

http://www.lebans.com/loadjpeggif.htm

Download the file A2KLoadJpegGifGDIPlus.zip and extract the .mdb sample from
it. Open the form named "frmStdPicToPictureData" (do not open the subform
named "JpegGifSubForm"). Are you able to load an image into this form, on the
Windows XP machine?

Experiment # 3:
Try downloading and installing the .dll file found in the "GDI+DLL.zip"
download that Stephan makes available.


Tom Wickerath
Microsoft Access MVP
https://mvp.support.microsoft.com/profile/Tom
http://www.access.qbuilt.com/html/expert_contributors.html
__________________________________________
 
R

Ray

Experiment 1:

this is what showed up in the immediate window:
Me.PaintPalette: `A @ ` ? À à † ? ?0 ? ? ? ?? ? .... (about 4 lines
worth)
[ImageFrame].Picture: (none)
fName: C:\temp\Blue hills.jpg

Me.PaintPalette: `A @ ` ? À à † ? ? 0 ? ? ? ? ? ...
[ImageFrame].Picture: (none)
fName: C:\temp\sunset.jpg

Experiment 2: Yes, I can get images to load, but oddly enough it wouldn't
load the images that I had previously entered into your ImageDemo. I tried
two different pictures that loaded fine in Stephen Leban's form, put them
into your database, and when I returned to the Leban's the pictures would no
longer load.

This brings me to another issue that I think may be related - the XP machine
shows the record locking info file for a database even when the database is
closed and I am the only person who has ever used it. Then it tries to lock
me out of the database when I reopen it - or it won't open it at all.

Experiment 3:
The instructions say: "For Windows XP use the system-supplied gdiplus.dll.
Do not install a new gdiplus.dll over the system-supplied version (it will
fail due to Windows File Protection)."

Tom Wickerath said:
Hi Ray,

The code in the frmEmployees form, in my ImageDemo sample, came from a copy
of Northwind. The "picture not found" response that you see is from code in
this form's Current event procedure. It turns out that this code includes On
Error Resume Next, so it is not going to result in an error number or message
similar to what you are seeing with your database being displayed.

I'd like you to try an experiment using my ImageDemo sample on the Windows
XP machine. First, open the tblEmployees table in normal view, and scroll
horizontally until you see the field named "Photo". For Employee ID 5, Steven
Buchanan, and for Employee ID 8, Laura Callahan, enter valid paths to two
images saved in some folder on your hard drive. For example:

C:\Temp\Picture1.jpg and
C:\Temp\Picture2.jpg

(I'm having you enter paths to valid pictures for these two people, since
the form's recordset is ordered ascending by lastname, and firstname--these
are the first two records that you should see).

Then open the frmEmployees form in design view. Then click on View > Code.
Scroll down to where you should see the Current event procedure for this form:

Private Sub Form_Current()

Add some Debug.Print statements, as indicated below:

Me![ImageFrame].Picture = fName
ShowImageFrame
Me.PaintPalette = Me![ImageFrame].ObjectPalette

Debug.Print "Me.PaintPalette: " & Me.PaintPalette
Debug.Print "[ImageFrame].Picture: " & Me![ImageFrame].Picture
Debug.Print "fName: " & fName
Debug.Print

If (Me![ImageFrame].Picture <> fName) Then
HideImageFrame
errormsg.Caption = "Picture not found"
errormsg.Visible = True
End If

Minimize the code window. Reopen the form in normal mode, and then use the
navigation button to move to record # 2 for Laura Callahan. Then tap <Ctrl>
<G> (the Control and G keys, at the same time) to open the Immediate window.
You should see something like the following:

Me.PaintPalette: `A @ ` ? À à † ? ? 0 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
?[ImageFrame].Picture: C:\Temp\Picture1.jpg
fName: C:\Temp\Picture1.jpg

Me.PaintPalette: `A @ ` ? À à † ? ? 0 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
[ImageFrame].Picture: C:\Temp\Picture2.jpg
fName: C:\Temp\Picture2.jpg

The first line for each image will be a bunch of weird characters (I'm not
showing the entire contents of the first line). The point is that *something*
similar should be printed to the Immediate Window for Me.PaintPalette. I'm
thinking that something is interferring with the ObjectPalette property on
your system. Here is some information that I copied from the Access 2003 Help
system, when I selected the word ObjectPalette in the Current event
procedure, and pressed the F1 button to bring up context-sensitive Help:

If the application associated with the OLE object, bitmap, or other graphic
doesn't have an associated palette, the ObjectPalette property is set to an
zero-length string.

The setting of the ObjectPalette property makes the palette of the
application associated with the OLE object, bitmap, or other graphic
contained in a control available to the PaintPalette property of a form or
report.
=====================================

Experiment # 2:
Please navigate to Access MVP Stephen Leban's page here:

http://www.lebans.com/loadjpeggif.htm

Download the file A2KLoadJpegGifGDIPlus.zip and extract the .mdb sample from
it. Open the form named "frmStdPicToPictureData" (do not open the subform
named "JpegGifSubForm"). Are you able to load an image into this form, on the
Windows XP machine?

Experiment # 3:
Try downloading and installing the .dll file found in the "GDI+DLL.zip"
download that Stephan makes available.


Tom Wickerath
Microsoft Access MVP
https://mvp.support.microsoft.com/profile/Tom
http://www.access.qbuilt.com/html/expert_contributors.html
__________________________________________

Ray said:
Thanks for responding,

Your image demo worked fine on my 2000 computer, but not on the XP. On XP,
it doesn't give the same error, but rather it just says "picture not found."
I looked at the references and couldn't find anything missing or out of date.
As far as I can tell, article 319832 doesn't apply because it doesn't work
at all, even once, but I think perhaps I am in a bit over my head here.
 
T

Tom Wickerath

Hi Ray,
this is what showed up in the immediate window:
Me.PaintPalette: `A @ ` ? À à † ? ?0 ? ? ? ?? ? .... (about 4 lines
worth)
[ImageFrame].Picture: (none)
fName: C:\temp\Blue hills.jpg

Sorry for the delayed reply. I think the key to solving this problem is
trying to figure out why the second debug.print statement indicates that the
..Picture property of the control is none, especially when one considers the
error message that you receive in your application:

-2147417848 Method picture of object_image failed

Another MVP asked the following question:

"Probably obvious, but can he actually navigate to the folder containing the
pictures (using the path that I assume is stored in the tables) if he uses
Windows Explorer? Does his computer have access to that folder?"

=======================

What happens if you try to hard code the .Picture property, using a valid
path on the WindowsXP computer, which contains an image that you can navigate
to using Windows Explorer? For example:

Me![ImageFrame].Picture = "C:\temp\sunset.jpg"
ShowImageFrame
Me.PaintPalette = Me![ImageFrame].ObjectPalette

=================================

What service packs do you have applied for both Windows XP and for Access?
For Windows XP, click on Start > Run, and type the command WinVer. For
Access, open Access and click on Help > About Microsoft Access. Both should
be indicating SP-2.


Tom Wickerath
Microsoft Access MVP
https://mvp.support.microsoft.com/profile/Tom
http://www.access.qbuilt.com/html/expert_contributors.html
__________________________________________

Ray said:
Experiment 1:

this is what showed up in the immediate window:
Me.PaintPalette: `A @ ` ? À à † ? ?0 ? ? ? ?? ? .... (about 4 lines
worth)
[ImageFrame].Picture: (none)
fName: C:\temp\Blue hills.jpg

Me.PaintPalette: `A @ ` ? À à † ? ? 0 ? ? ? ? ? ...
[ImageFrame].Picture: (none)
fName: C:\temp\sunset.jpg

Experiment 2: Yes, I can get images to load, but oddly enough it wouldn't
load the images that I had previously entered into your ImageDemo. I tried
two different pictures that loaded fine in Stephen Leban's form, put them
into your database, and when I returned to the Leban's the pictures would no
longer load.

This brings me to another issue that I think may be related - the XP machine
shows the record locking info file for a database even when the database is
closed and I am the only person who has ever used it. Then it tries to lock
me out of the database when I reopen it - or it won't open it at all.

Experiment 3:
The instructions say: "For Windows XP use the system-supplied gdiplus.dll.
Do not install a new gdiplus.dll over the system-supplied version (it will
fail due to Windows File Protection)."
 
R

Ray

1. Yes, I can navigate directly to the photos in Windows and open them.
Oddly enough, they won't open with Microsoft Photo Editor, which was set as
the default program to open the photos - that program crashes when I try to
open the photos, but they open fine with other programs: MS Picture and Fax
Viewer, MS Paint, MS Office Picture Manager, etc.

2. I can't get it to work when I hard code it.

3. Both Access and XP show SP2.

Converting the jpg files to bitmaps and (changing the paths in my tables
from .jpg to .bmp) seems to fix the problem. It's not ideal, but if I can't
figure something else out pretty quickly, I may have to just settle for that
solution for now.




Tom Wickerath said:
Hi Ray,
this is what showed up in the immediate window:
Me.PaintPalette: `A @ ` ? À à † ? ?0 ? ? ? ?? ? .... (about 4 lines
worth)
[ImageFrame].Picture: (none)
fName: C:\temp\Blue hills.jpg

Sorry for the delayed reply. I think the key to solving this problem is
trying to figure out why the second debug.print statement indicates that the
.Picture property of the control is none, especially when one considers the
error message that you receive in your application:

-2147417848 Method picture of object_image failed

Another MVP asked the following question:

"Probably obvious, but can he actually navigate to the folder containing the
pictures (using the path that I assume is stored in the tables) if he uses
Windows Explorer? Does his computer have access to that folder?"

=======================

What happens if you try to hard code the .Picture property, using a valid
path on the WindowsXP computer, which contains an image that you can navigate
to using Windows Explorer? For example:

Me![ImageFrame].Picture = "C:\temp\sunset.jpg"
ShowImageFrame
Me.PaintPalette = Me![ImageFrame].ObjectPalette

=================================

What service packs do you have applied for both Windows XP and for Access?
For Windows XP, click on Start > Run, and type the command WinVer. For
Access, open Access and click on Help > About Microsoft Access. Both should
be indicating SP-2.


Tom Wickerath
Microsoft Access MVP
https://mvp.support.microsoft.com/profile/Tom
http://www.access.qbuilt.com/html/expert_contributors.html
__________________________________________

Ray said:
Experiment 1:

this is what showed up in the immediate window:
Me.PaintPalette: `A @ ` ? À à † ? ?0 ? ? ? ?? ? .... (about 4 lines
worth)
[ImageFrame].Picture: (none)
fName: C:\temp\Blue hills.jpg

Me.PaintPalette: `A @ ` ? À à † ? ? 0 ? ? ? ? ? ...
[ImageFrame].Picture: (none)
fName: C:\temp\sunset.jpg

Experiment 2: Yes, I can get images to load, but oddly enough it wouldn't
load the images that I had previously entered into your ImageDemo. I tried
two different pictures that loaded fine in Stephen Leban's form, put them
into your database, and when I returned to the Leban's the pictures would no
longer load.

This brings me to another issue that I think may be related - the XP machine
shows the record locking info file for a database even when the database is
closed and I am the only person who has ever used it. Then it tries to lock
me out of the database when I reopen it - or it won't open it at all.

Experiment 3:
The instructions say: "For Windows XP use the system-supplied gdiplus.dll.
Do not install a new gdiplus.dll over the system-supplied version (it will
fail due to Windows File Protection)."
 
T

Tom Wickerath

Hi Ray,
Oddly enough, they won't open with Microsoft Photo Editor, which was set as
the default program to open the photos - that program crashes when I try to
open the photos, but they open fine with other programs: MS Picture and Fax
Viewer, MS Paint, MS Office Picture Manager, etc.

Okay, I think we are slowly getting somewhere. Find the line of code that
reads as follows (just above where I previously had you insert the
Debug.Print statements):

Me.PaintPalette = Me![ImageFrame].ObjectPalette

Click your mouse so that the cursor is blinking within "ObjectPalette", and
then hit the F1 key to open context-sensitive Help. One of the things I see
is the following:
=====================
"If the application associated with the OLE object, bitmap, or other graphic
doesn't have an associated palette, the ObjectPalette property is set to an
zero-length string.

The setting of the ObjectPalette property makes the palette of the
application associated with the OLE object, bitmap, or other graphic
contained in a control available to the PaintPalette property of a form or
report."
=====================

If your default program is crashing when you attempt to open the image, then
it's very likely not making it's palette available to the PaintPalette
property (at least that's my guess). This KB article suggest that
re-registering the shimgvw.dll file might help:

You cannot view pictures by using Windows Picture
and Fax Viewer in Windows XP
http://support.microsoft.com/kb/921048

And this KB article looks *very* interesting, because the Windows Picture
and Fax Viewer uses the GDI+ API in Windows XP:

A program may not be able to display an image by using
the GDI+ API in Windows XP
http://support.microsoft.com/kb/889412

Can you try getting the hotfix and see is this helps?


Tom Wickerath
Microsoft Access MVP
https://mvp.support.microsoft.com/profile/Tom
http://www.access.qbuilt.com/html/expert_contributors.html
__________________________________________
 
R

Ray

Sorry for the delay - I have been very busy and this project has taken a bit
of a back seat.

Nothing seemed to change in Access when I made the Windows Picture and Fax
Viewer my default program for images.
 
R

Ray

I just downloaded Office 2003 SP3 from office update, and that fixed the
problem, whatever it was. I can now open the JPEG files in both Access and
Photo editor. I still have no idea what the problem was, but it seems to
have resolved itself.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top