Embedding graphics in an OLE field

  • Thread starter Thread starter Rick Brown
  • Start date Start date
R

Rick Brown

I use Access97 & Win98se.
To simulate a toggle button, I have two Image boxes, one atop the other.
Currently the ON.bmp and OFF.bmp graphics are stored in the same folder as
the MDB file. Since I only have the two graphics, I would like to store them
in a table's OLE Object field.
I can make all this happen except what the syntax is to point toward the
graphics now in the table.
My current code looks like this and now I want it to point to the table so I
can eliminate external baggage.

Private Sub Image38_Click()
If Image38.Picture = "C:\Machine Lineup Tags\OFF.bmp" Then
Image38.Picture = "C:\Machine Lineup Tags\ON.bmp"
Else
Image38.Picture = "C:\Machine Lineup Tags\OFF.bmp"
End If
End Sub

Thanks for any help,
RICK
 
DO you want to store the Images externally of the Form because you will
be using the "toggle button images" on more than 1 form or for multiple
controls?
If not then simply embedd the Images directly in two Image controls and
make then visible/invisible as required.

If multiple instances will be required then you have a couple of
options:

1) You can reference the PictureData property of the control as long as
the Form is open. For example:
Form2.ImageControSlave.PictureData =
Form1.ImageControMaster1.PictureData
or
2) Copy the PictureData prop of the two master Image controls to your
long binary OLE field.
Assuming a binary field(not control name!) named "Binary" then use code
like:
Me.Binary = Me.ImageControMaster1.PictureData
or
3) COpy the contents of the original image file(s) as is directly into
your long binary OLE field.
a) Read the entire file into a byte array
b) Copy the byte array into the binary field
WHen you need the image data you would have to:
c) Copy the contents of the binary field out to a temp disk file
d) Load the temp disk file into the Picture prop of the Image control


I prefer option #2.


HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
Rick please keep all correspondance in the NG's where it belongs and
where my SIG line states this as well.

If you are using the standard Access Image control, not the OLE Frame
control, then as long as your Image control's PictureType property is
set to Embedded, then you can certainly remove the original source file
as it is no longer required.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
<<<Rick please keep all correspondance in the NG's where it belongs >>>
Sorry, I must have hit Reply in error.

<<<Image control's PictureType property is set to Embedded,>>>

I was still trying to use one Image control to toggle both pics, once I put
one atop the other all else made sense.
Thanks for your time.
RICK
 
Back
Top