PC Review


Reply
Thread Tools Rate Thread

Attachment image as image picture

 
 
Brian
Guest
Posts: n/a
 
      26th Mar 2010
I am trying to set an image dynamically at runtime. I have several images
stored in a table using a single attacment per record.
I can already determine the correct image and retreive it's data using :
rsForm.Fields("Images").Value
however when i try to set the image to this:
imgTestPic.PictureData = rsForm.Fields("Images").Value
i get the following error: 2192: The bitmap you specified is not in a
device-independent bitmap (.dib) format.
I can however set the image to an external file:
imgTestPic.Picture = "C:\testicon.ico" so the setting works.
So how do i convert my stored Imagge bitmap to a DIB???
Geatly appreciate any assistance...

 
Reply With Quote
 
 
 
 
Jack Leach
Guest
Posts: n/a
 
      27th Mar 2010
AFIAK, to display an image in a standard picture control, it does not need to
be a DIB format file.

You first reference the .PictureData property, then the .Picture property...
did you perhaps have a typo? Have you tried setting the .Picture property
with the field value rather than the PictureData property?

As a side note, I generally always store the image in a folder (either the
BE folder or FE app folder depending on the nature of the image) and set the
Picture property of the image control to the path of the file.

hth
--
Jack Leach
www.tristatemachine.com

"I haven''t failed, I''ve found ten thousand ways that don''t work."
-Thomas Edison (1847-1931)



"Brian" wrote:

> I am trying to set an image dynamically at runtime. I have several images
> stored in a table using a single attacment per record.
> I can already determine the correct image and retreive it's data using :
> rsForm.Fields("Images").Value
> however when i try to set the image to this:
> imgTestPic.PictureData = rsForm.Fields("Images").Value
> i get the following error: 2192: The bitmap you specified is not in a
> device-independent bitmap (.dib) format.
> I can however set the image to an external file:
> imgTestPic.Picture = "C:\testicon.ico" so the setting works.
> So how do i convert my stored Imagge bitmap to a DIB???
> Geatly appreciate any assistance...
>

 
Reply With Quote
 
Brian H
Guest
Posts: n/a
 
      29th Mar 2010
Hi Jack Thanks for trying, but...

setting TestPic.PictureData = rsForm!icon.Value
seems to load somthing but does not display an image!

setting TestPic.Picture = rsForm!icon.Value
results in a Type mismatch

Pretty sure there are no typo's

"Jack Leach" wrote:

> AFIAK, to display an image in a standard picture control, it does not need to
> be a DIB format file.
>
> You first reference the .PictureData property, then the .Picture property...
> did you perhaps have a typo? Have you tried setting the .Picture property
> with the field value rather than the PictureData property?
>
> As a side note, I generally always store the image in a folder (either the
> BE folder or FE app folder depending on the nature of the image) and set the
> Picture property of the image control to the path of the file.
>
> hth
> --
> Jack Leach
> www.tristatemachine.com
>
> "I haven''t failed, I''ve found ten thousand ways that don''t work."
> -Thomas Edison (1847-1931)
>
>
>
> "Brian" wrote:
>
> > I am trying to set an image dynamically at runtime. I have several images
> > stored in a table using a single attacment per record.
> > I can already determine the correct image and retreive it's data using :
> > rsForm.Fields("Images").Value
> > however when i try to set the image to this:
> > imgTestPic.PictureData = rsForm.Fields("Images").Value
> > i get the following error: 2192: The bitmap you specified is not in a
> > device-independent bitmap (.dib) format.
> > I can however set the image to an external file:
> > imgTestPic.Picture = "C:\testicon.ico" so the setting works.
> > So how do i convert my stored Imagge bitmap to a DIB???
> > Geatly appreciate any assistance...
> >

 
Reply With Quote
 
Jack Leach
Guest
Posts: n/a
 
      29th Mar 2010
Have you checked the help file on the .PictureData property? I don't believe
this is what you want... it is used for transferring properties from one
object to another and doesn't seem to have a place in your situation.

The .Picture property takes a String datatype... ex.
"C:\SomeFolder\SomeFile.bmp" If you are getting a type-mismatch then you are
not supplying it with a string value. What is the value of
rsForm!icon.Value? For the record, icon may be a reserved word (not sure on
this, but I'd avoid using any word that has meaning aside from your control.
Maybe you should prefix it with "img" or "ctl" or something).

Also, you should make sure the PictureType property is set to Linked rather
than Embedded.


--
Jack Leach
www.tristatemachine.com

"I haven''t failed, I''ve found ten thousand ways that don''t work."
-Thomas Edison (1847-1931)



"Brian H" wrote:

> Hi Jack Thanks for trying, but...
>
> setting TestPic.PictureData = rsForm!icon.Value
> seems to load somthing but does not display an image!
>
> setting TestPic.Picture = rsForm!icon.Value
> results in a Type mismatch
>
> Pretty sure there are no typo's
>
> "Jack Leach" wrote:
>
> > AFIAK, to display an image in a standard picture control, it does not need to
> > be a DIB format file.
> >
> > You first reference the .PictureData property, then the .Picture property...
> > did you perhaps have a typo? Have you tried setting the .Picture property
> > with the field value rather than the PictureData property?
> >
> > As a side note, I generally always store the image in a folder (either the
> > BE folder or FE app folder depending on the nature of the image) and set the
> > Picture property of the image control to the path of the file.
> >
> > hth
> > --
> > Jack Leach
> > www.tristatemachine.com
> >
> > "I haven''t failed, I''ve found ten thousand ways that don''t work."
> > -Thomas Edison (1847-1931)
> >
> >
> >
> > "Brian" wrote:
> >
> > > I am trying to set an image dynamically at runtime. I have several images
> > > stored in a table using a single attacment per record.
> > > I can already determine the correct image and retreive it's data using :
> > > rsForm.Fields("Images").Value
> > > however when i try to set the image to this:
> > > imgTestPic.PictureData = rsForm.Fields("Images").Value
> > > i get the following error: 2192: The bitmap you specified is not in a
> > > device-independent bitmap (.dib) format.
> > > I can however set the image to an external file:
> > > imgTestPic.Picture = "C:\testicon.ico" so the setting works.
> > > So how do i convert my stored Imagge bitmap to a DIB???
> > > Geatly appreciate any assistance...
> > >

 
Reply With Quote
 
Brian H
Guest
Posts: n/a
 
      29th Mar 2010
Hi Jack,
Yes the .Picture prop takes a string usually a file path/name.
I am using an attacment field in a form as the image source.

the code is:
Static frmImages As Form
Static rsForm As DAO.Recordset2
DoCmd.OpenForm "Icons" 'WindowMode:=acHidden
Set frmImages = Forms("Icons")
Set rsForm = frmImages.Recordset
rsForm.FindFirst "Description='" & "Face'"
If rsForm.NoMatch Then
' No image found
Else
Me.TestPic.Picture = rsForm!imgSource.Value '=Type Mismatch
Me.TestPic2.PictureData = rsForm.Fields("imgSource").Value '=
Nothing happens but Me.TestPic2.PictureData remains Null.
Me.Repaint
Me.Requery
End If

So how do i get an image from the attachment to an image control other than
Picturedata???

"Jack Leach" wrote:

> Have you checked the help file on the .PictureData property? I don't believe
> this is what you want... it is used for transferring properties from one
> object to another and doesn't seem to have a place in your situation.
>
> The .Picture property takes a String datatype... ex.
> "C:\SomeFolder\SomeFile.bmp" If you are getting a type-mismatch then you are
> not supplying it with a string value. What is the value of
> rsForm!icon.Value? For the record, icon may be a reserved word (not sure on
> this, but I'd avoid using any word that has meaning aside from your control.
> Maybe you should prefix it with "img" or "ctl" or something).
>
> Also, you should make sure the PictureType property is set to Linked rather
> than Embedded.
>
>
> --
> Jack Leach
> www.tristatemachine.com
>
> "I haven''t failed, I''ve found ten thousand ways that don''t work."
> -Thomas Edison (1847-1931)
>
>
>
> "Brian H" wrote:
>
> > Hi Jack Thanks for trying, but...
> >
> > setting TestPic.PictureData = rsForm!icon.Value
> > seems to load somthing but does not display an image!
> >
> > setting TestPic.Picture = rsForm!icon.Value
> > results in a Type mismatch
> >
> > Pretty sure there are no typo's
> >
> > "Jack Leach" wrote:
> >
> > > AFIAK, to display an image in a standard picture control, it does not need to
> > > be a DIB format file.
> > >
> > > You first reference the .PictureData property, then the .Picture property...
> > > did you perhaps have a typo? Have you tried setting the .Picture property
> > > with the field value rather than the PictureData property?
> > >
> > > As a side note, I generally always store the image in a folder (either the
> > > BE folder or FE app folder depending on the nature of the image) and set the
> > > Picture property of the image control to the path of the file.
> > >
> > > hth
> > > --
> > > Jack Leach
> > > www.tristatemachine.com
> > >
> > > "I haven''t failed, I''ve found ten thousand ways that don''t work."
> > > -Thomas Edison (1847-1931)
> > >
> > >
> > >
> > > "Brian" wrote:
> > >
> > > > I am trying to set an image dynamically at runtime. I have several images
> > > > stored in a table using a single attacment per record.
> > > > I can already determine the correct image and retreive it's data using :
> > > > rsForm.Fields("Images").Value
> > > > however when i try to set the image to this:
> > > > imgTestPic.PictureData = rsForm.Fields("Images").Value
> > > > i get the following error: 2192: The bitmap you specified is not in a
> > > > device-independent bitmap (.dib) format.
> > > > I can however set the image to an external file:
> > > > imgTestPic.Picture = "C:\testicon.ico" so the setting works.
> > > > So how do i convert my stored Imagge bitmap to a DIB???
> > > > Geatly appreciate any assistance...
> > > >

 
Reply With Quote
 
Dirk Goldgar
Guest
Posts: n/a
 
      30th Mar 2010
"Brian H" <(E-Mail Removed)> wrote in message
news:8BEA2517-63D9-4948-8A34-(E-Mail Removed)...
> Hi Jack,
> Yes the .Picture prop takes a string usually a file path/name.
> I am using an attacment field in a form as the image source.
>
> the code is:
> Static frmImages As Form
> Static rsForm As DAO.Recordset2
> DoCmd.OpenForm "Icons" 'WindowMode:=acHidden
> Set frmImages = Forms("Icons")
> Set rsForm = frmImages.Recordset
> rsForm.FindFirst "Description='" & "Face'"
> If rsForm.NoMatch Then
> ' No image found
> Else
> Me.TestPic.Picture = rsForm!imgSource.Value '=Type Mismatch
> Me.TestPic2.PictureData = rsForm.Fields("imgSource").Value '=
> Nothing happens but Me.TestPic2.PictureData remains Null.
> Me.Repaint
> Me.Requery
> End If
>
> So how do i get an image from the attachment to an image control other
> than
> Picturedata???



I suggest you poke around a bit on www.lebans.com . Stephen Lebans has done
some pretty complicated work with image processing in Access. Also, Larry
Linson has an example where he writes the BLOB to a temporary file, then
sets an Image control's Picture property to that file's path. That's in his
Imaging Examples database, which can be downloaded from
http://accdevel.tripod.com/imaging.htm .

--
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)

 
Reply With Quote
 
Brian H
Guest
Posts: n/a
 
      30th Mar 2010
Hi Dirk, Yes Steven Lebans stuff is amazing! I was hoping for a slightly
simpler solution than a full API Class conversion. I must admit I am
surprised how hard MS have made it to use the Attachment objects.
I think i will go with the external File folder rather than spend a week
coding the GDI API. But this would be a good challenge if I ever find some
spare time!!!
Thanks to both you and jack for trying...
Brian.
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel Image or Picture from SQL Image Data Type Sam K Microsoft Excel Programming 0 1st Dec 2008 11:04 PM
Control image property locking image file even after image cleared steve Microsoft VB .NET 4 6th Jul 2006 02:57 AM
Sizing Image to Report (Was Picture in Image Box in Formscoding and Modulesvba) Kahuna Microsoft Access Reports 0 1st Oct 2005 09:39 AM
Picture Image is stripped and sent as email attachment =?Utf-8?B?SmVmZiBN?= Microsoft Word Document Management 1 10th Jun 2005 03:58 AM
Windows Picture and Fax Viewer & image.gif attachment Clark H Lewis Windows XP Photos 1 18th Oct 2003 08:15 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:45 PM.