Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Picture control and Access data

Status
Not open for further replies.

rann

Programmer
Sep 13, 2001
86
US
Hi,
I have a picture control on a form that displays bmp files
stored in a Access database.

I use

" Picture1.Picture = LoadPicture(rstData.Fields("Photo")) "

to display the bmp image from the table(rstData is a recordset).
But this does not display the bmp file.

Any help or links would be appreciated,

Thanks in Advance,

Rann.

 
LoadPicture() is looking for a path and filename as a string, not OLE binary data.

The recommended method for storing images is to store the full path to the pictures in your database and then use LoadPicture(rst!FullFileName) to open them.

If you want to load the binary data to the Picture control you have to BLOB the data out to a temporary file and then use its path and filename with LoadPicture() to load it.

There is a rather lengthy example in the knowledge base: Q147727

VBSlammer
redinvader3walking.gif
 

Or just use the OLE Container control and DAO....

You can use DAO in the same project as ADO, so why not take advantage of it?

Set the DataSource of the OLE Container to a DAO Datacontol and the OLE Container's DataField to the OLE field name in the database. Just add the DAO data control to the form with-out setting any properties, and then create a DAO recordset and set the data control's recordset to the rs object:

Set Data1.Recordset = myRS

The Data Control will take all of the connection info from the recordset.

Of course, seeing's how this is an OLE container, an application that can open Bmp files (like MS Paint) must be present on the machine.

This method works for any OLE type: Excel files, Word files, etc.. Again, you need to have a application on your machine that can open these files. Then the OLE containe will use these applications to open present the data (of course, the file must be associated with the application).
You can also allow or prevent the user from editing the file when right mouse clicking on the container, and if they can edit the data, you can have the associated application open with-in the container, looking as if it is part of your application (you will need a default menu item on your form, and set the NegotiateMenus property of the form to True, and NegotiateToolbars of your MDI form also to true, in order to see the application's menu items), or you can have the application itself open up with the data. [/b][/i][/u]*******************************************************
General remarks:
If this post contains any suggestions for the use or distribution of code, components or files of any sort, it is still your responsibility to assure that you have the proper license and distribution rights to do so!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top