Clearing Out OLE Embedded Object

T

The Merg

Okay, this question relates to an app in VB6, but the underlying issue I
have is with the Access DB backend, so I figured I'd try my question here.

In my database, I have an OLE Object field that I place graphics into via
the VB6 app. I also have the app remove the pictures from the field, if
desired. However, when removing the pictures from the field, if I look at
the field in the database, it still has the text in it of "Long Binary
Data". When I later check the field via the app to see if it's empty/null,
it is not. When I clear out the field, I would like to it clear out
completely. Does anyone know how this is done via code in Access? I figure I
can adapt code in Access to that which I can use in VB.

Thanks,
The Merg
 
T

The Merg

The object the picture is loaded into in the VB app is an Image Box control
that is bound to the OLE Object field in Access using DAO. In order to clear
out the picture, I use the code:

Set pic_Photo.Picture = LoadPicture()

although I have also tried:

Set pic_Photo.Picture = Nothing

This does update the database and when the record is viewed later on, no
picture is present. However, I do need to check for the presence of a
picture in the database during another routine. The only way I can think of
doing that is to see if the OLE Object field in Access is null/empty. When
removing the picture using the above code, it gets rid of the picture, but
does not empty out the field.

Thanks,
The Merg
 
T

TC

The said:
The object the picture is loaded into in the VB app is an Image Box control
that is bound to the OLE Object field in Access using DAO.

Ok, got that.
In order to clear out the picture, I use the code:
Set pic_Photo.Picture = LoadPicture()
although I have also tried:
Set pic_Photo.Picture = Nothing

As a WHAG (wild half-assed guess), I suggest creating a temporary, new
unbound VB image box control and displaying the value of the Picture
property before you've put anything in there. That would show you the
data type of that property. Pehaps it is Null, or 0, or somesuch.

Stephen Lebans knows tons about ths. He could undoubtedly answer your
question. If you can't work it out, post again, including his name in
the subject, and he will probably see it. (I'm surprised that he hasn't
already.) Check what groups he is using at present, perhaps he does not
check this one. (Just go to groups.google.com & use the advanced search
option.)

HTH,
TC (MVP Access)
http://tc2.atspace.com
 
T

The Merg

Well, I think I gotta workaround on this one. More on that in a sec...

Regarding the data type, it displays as a long, as when it's 0, there is no
picture present or if no picture has ever been in the field it is null. As
soon as something is put into the field it has a value that is <> 0, which
is how I do my checking. When removing the picture, the value goes back to
0, but the field is not emptied out. In my code elsewhere in the app if I
check to see if the value of the field is 0, I get a Type Mismatch error as
I can't check the value of a OLE Object.

What I ended up doing is that in the validate event of the data control, I
checked to see if the value of the Image Box was 0 and the datachanged
property was true. If it was, I perform a datacontrol Edit, manually set the
field to be null, and then a datacontrol Update. Not the best way of doing
things, I'm sure, but it works. I got to thinking of that from your question
of "what code do you use to remove the picture from the field".

Thanks,
Merg
 
S

Stephen Lebans

It's a Variant data type. Set it to NULL.
To see if it is empty do something using Not IsNull or IsNull.
--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 

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

Similar Threads


Top