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

Access OLE & VB6 1

Status
Not open for further replies.

Anesthaesia

Technical User
Aug 30, 2001
126
GB
How can I take an OLE picture object from and Access database, and display it in a picture box in VB ?
 
This isn't exactlly what your looking for but this is how I store a picture in a database ole object. I've never had to get the picture out from vb, I've only put it in so it can be displayed on reports. Maybe it will help you in the right direction. GetChunk might be what you need.


'''''''''''''''''''''''''''''''''''''''''''
Dim SFName As String
Dim iFileNum As Long
Dim z() As Byte
Dim FileNum As Integer

FileNum = FreeFile

SFName = txtCompanyLogo.Text
If SFName = "" Then GoTo SkipLogo
Open SFName For Binary Access Read As FileNum
ReDim z(FileLen(SFName))
Get FileNum, , z()
adoRec!logo.AppendChunk z
Close FileNum

'''''''''''''''''''''''''''''''''''''''
 
hello !

I tried saving the picture from the picture box (the picture was lines,shapes,boxes etc) and I was successfull to save it and retrieve it from the access database into a picture box.

Now I want to display the same picture into the crystal report. do you have any idea how to do this, I tried using ole object control but uses only the path of the file to display the image on the crystal report.

Thanks !!


 
I think you might be looking for a harder way than it really is. If I remember correctly (If I'm wrong let me know and I'll check) all you need to do is add it to the report just like you would any other database field. I always displayed the logo in a subreport in the header. I'm not sure why but it might be because I made a seperate connection to the table it was stored in, or you could include it in your main sql. For whatever reason I must have found it easier to do it in a subreport so you might want to do it that way.

Tom
 
Yes, you can add it just like wou would any other db field, or you could insert it as a blob object if it is stored in a file.
Doing it the second way, and keeping it also dynamic, would mean using a generic name for the file that is to be inserted, and copying the actual file that you want inserted into the same folder, or a sub folder, as the rpt, using the generic name.

For both ways mentioned, because we are talking about an OLE object as opposed to an embedded object, the client pc must have a program on it that can also open that file.
This means that if the OLE object is a Word doc, then MS Word (and dependending on the format, WordPad may be used) or an application that can open Word docs, must be on the pc as well; If a picture stored in Tiff format, then an application must be on the machine that can open these types of files as well.
 
Thanks for the reply.

But my picture is stored into the access database as Long Binary Data, this field does not even show up in the list of fields while am trying to generate the crystal query.
am little confused. If you want I can post the code to save & display picture box image.

It is b'use it is access database.

Code example will also be helpful.

Please reply !

Thanks

 
You probably need to "verify" the database. I'm going on the assumption that you added the field after you linked the report to the table or query. Or just make sure the field is in your sql statement, if its included as TableName.* then verifying should do the trick.

I too use access databases and store the data as Long Binary Data so that is not the problem.

Tom
 
Hello

I used Tlowder's method to add gif's to a field (ole-object) in my database (access 2000). This works fine. When I open the database in access I can see that the file is stored as 'long binary file'.
When I add this field to a crystal report (I'm using the crystal control in vb) this field is a blob, but the picture isn't visible on the report...
I already tested to manualy insert the picture in the database and then adding it to a crystal report. Under these circumstances the picture is visible on the report.

Am I doing something wrong?

greetz

Mim
 
Hello

I used Tlowder's method to add gif's to a field (ole-object) in my database (access 2000). This works fine. When I open the database in access I can see that the file is stored as 'long binary file'.
When I add this field to a crystal report (I'm using the crystal control in vb) this field is a blob, but the picture isn't visible on the report...
I already tested to manualy insert the picture in the database and then adding it to a crystal report. Under these circumstances the picture is visible on the report.

Am I doing something wrong?

greetz

Mim
 
Hello again!

Sorry for my previous double post... I had a little problem with my internet connection.

I have found where my problem was!!

This thread explains it all! I would advise to take a look at it:
thread149-18866

greetz to all

Mim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top