p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

vba_access thread: Re: OLE Picture objects and embedding programatically


Message #1 by matt@p... on Tue, 10 Jul 2001 17:31:56
This works..and in the picture column i get the 'long binary data' but it 
does not display as a photo...any ideas?


> > I was given the following code for a similar project:
> 
> 
> Method to get a picture from a database:
> 
> Dim lngImageSize As Long
> Dim lngOffset As Long
> Dim bytChunk() As Byte
> Dim intFile As Integer
> Dim strTempPic As String
> Const conChunkSize = 100
> Dim strImage As String
> 
> intFile = FreeFile
> Open strTempPic For Binary As # intFile
> lngImageSize = rs("ImageBLOB").ActualSize
> Do While lngOffset < lngImageSize
>  bytChunk() = rs("ImageBLOB").GetChunk( conChunkSize)
>  Put # intFile, , bytChunk()
>  lngOffset = lngOffset + conChunkSize
> Loop
> Close # intFile
> 'set the value for a control, or html:
> imgDBImage.Picture = LoadPicture( strTempPic)
> Kill strTempPic
> 
> Method to send image file to database:
> 
> Dim bytBLOB() As Byte
> Dim strImagePath As String
> Dim intNum As Integer
> 
> intNum = FreeFile
> Open strImagePath For Binary As #intNum
> ReDim byteBLOB(FileLen( strImagePath))
> Get #intNum, , bytBLOB
> Close # intFile
> rs.Fields("ImageBLOB").AppendChunk bytBLOB
> rs.update
> 
> 
> John
> 
> 
> 
> 
> We have a picture roster we use for a local youth group and the 
membership 
> > system spits out the picture file name, the phone number and f/l names 
> of 
> > the kids.  Is there a way to programatically embed the actual picture 
> into 
> > a recordset without having to right click ourselves into oblivion?  I 
> > would like to automate this as much as I can.
> > 
> > Thanks tons!

  Return to Index