MartyConnelly
martyconnelly at shaw.ca
Wed Sep 6 19:13:45 CDT 2006
Assuming you have an embedded OLEfield that contains your photo,
in other words you have say a jpg within an OLE wrapper or header that
says what OLE server draws the image it could be Kodak Wang or
Paintbrush or .....
Otherwise you will have to use unembedded methods to handle just the blob
The blob could be an xml string, word .doc file or say a .gif as a
binary string.
So use this method.
http://www.lebans.com/loadsavejpeg.htm
If it is embedded; to copy ole field to another table use appendchunk
AppendChunk and GetChunk Methods Example
from Access 97 help
This example uses the AppendChunk and GetChunk methods to fill an OLE
object field with data from another record, 32K at a time. In a real
application, one might use a procedure like this to copy an employee
record (including the employee's photo) from one table to another. In
this example, the record is simply being copied back to same table. Note
that all the chunk manipulation takes place within a single
AddNew-Update sequence.
Sub AppendChunkX()
Dim dbsNorthwind As Database
Dim rstEmployees As Recordset
Dim rstEmployees2 As Recordset
Set dbsNorthwind = OpenDatabase("Northwind.mdb")
' Open two recordsets from the Employees table.
Set rstEmployees = _
dbsNorthwind.OpenRecordset("Employees", _
dbOpenDynaset)
Set rstEmployees2 = rstEmployees.Clone
' Add a new record to the first Recordset and copy the
' data from a record in the second Recordset.
With rstEmployees
.AddNew
!FirstName = rstEmployees2!FirstName
!LastName = rstEmployees2!LastName
CopyLargeField rstEmployees2!Photo, !Photo
.Update
' Delete new record because this is a demonstration.
.Bookmark = .LastModified
.Delete
.Close
End With
rstEmployees2.Close
dbsNorthwind.Close
End Sub
Function CopyLargeField(fldSource As Field, _
fldDestination As Field)
' Set size of chunk in bytes.
Const conChunkSize = 32768
Dim lngOffset As Long
Dim lngTotalSize As Long
Dim strChunk As String
' Copy the photo from one Recordset to the other in 32K
' chunks until the entire field is copied.
lngTotalSize = fldSource.FieldSize
Do While lngOffset < lngTotalSize
strChunk = fldSource.GetChunk(lngOffset, conChunkSize)
fldDestination.AppendChunk strChunk
lngOffset = lngOffset + conChunkSize
Loop
End Function
David & Joanne Gould wrote:
>I have a form for entering new movie stock into a Video Library database.
>This form also allows the user to update details for all copies of the
>title. Because of this the data is updated using code. One of the fields in
>the table is an image field. The code I am using is:
>
> 'Update Movie Title Details
> Dim rsUpdateMovieTitleDetails As Recordset
> Dim strMovieName As String
>
> strMovieName = Forms![frmAddNewMovieStock]![cboSelectMovieTitle]
>
> Set rsUpdateMovieTitleDetails = New ADODB.Recordset
> rsUpdateMovieTitleDetails.ActiveConnection = CurrentProject.Connection
> rsUpdateMovieTitleDetails.Open "tblTitles", , adOpenKeyset,
>adLockOptimistic, adCmdTable
>
> 'Loop through the recordset
> Do Until rsUpdateMovieTitleDetails.EOF
> If rsUpdateMovieTitleDetails.Fields("name") = strMovieName Then
> rsUpdateMovieTitleDetails.Fields("supplier") = Me.supplier
> rsUpdateMovieTitleDetails.Fields("rating") = Me.rating
> rsUpdateMovieTitleDetails.Fields("categoryName") = Me.categoryName
> rsUpdateMovieTitleDetails.Fields("RentalTypeID") = Me.RentalTypeID
> rsUpdateMovieTitleDetails.Fields("cover") = Me.oleCover
> End If
> rsUpdateMovieTitleDetails.MoveNext
> Loop
> rsUpdateMovieTitleDetails.Close
>
>I keep getting this error message:
>
>Multiple-step OLE DB operation generated errors. Check each OLE DB status
>value, if available. No work was done.
>
>Can anyone explain to me what I can do about this?
>
>TIA
>
>David Gould
>DG Solutions
>
>
>
>
--
Marty Connelly
Victoria, B.C.
Canada