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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to store a picture in a Public global variable 2

Status
Not open for further replies.

rew2009

Technical User
Apr 21, 2009
114
US
I have a form that has a data source ‘APTS’ and I am trying to store a field value directly into a Public global variable ‘sale.Picture’ and then transfer it into a second form controlled by a different table. When I do this with text fields with text boxes it works fine using code like:
saleOwnerName = Me.[OwnerName] from form1

Me.[OwnerName2] = saleOwnerName into a second form2

Where ‘saleOwnerName’ is a public variable declared as a variant. And this works fine, copying the text data to the new table.

However, if I do the same with a field in the table holding a picture (bmp) (OLE Object) where the Public variable is ‘sale.Picture’ as a variant, it does not work. I get no errors but it does not copy into the new table.

If I change the ‘salePicture’ Public variable type from ‘Variant’ to ‘Object’ I get the error: ‘Object variable or With Block variable not set’

How do you declare a public variable so that it will copy an OLE Object so it will copy correctly to the new table or do I need a different approach. I still want to use the Public Variable.

Thanks
 
I think you would have to create a class that has a bit array property to store the binary data. Your variable would then be an instance of that class. You would have to write code to load the stream of data into the array.

But I don't see any point to carying a picture around as a variable. You're not going to manipulate it, I assume (i.e. edit it, merge it with another picture, etc.). So the only you will do with it is:
1. Display it
2. Print it

For either of those, you can just use it directly from the database table. No need to use up resources to carry around a picture. If you want to copy to another table, you could use an SQL INSERT statement (although I wouldn't recommend having copies of the same picture in multiple tables - that's a great way to bloat your database).
 
Can you give more details on what your overall goal is? As Joe points out, it does not seem to make much sense. It seems to me that maybe you need a seperate picture table with each picture having an unique picture ID. Then both tables can link records by ID to a single picture table. You may also be able to do something like this. In form 2 you can set the recordsource of a bound object frame to
"=DLookUp("oleObj","query1","ID = " & [Forms]![form1]![ID])"

This then shows the image on form 2 selected in form 1.
 
You guys are right. I decided to use a picture table to accomplish the same thing.

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top