I am dynamically assigning a picture value to an image object. The code is
similar to what you see all over the news group:
Img.picture = "UNC_Path"
The issue I am having is similar to most others where the report is
generating a page with an image on it where there are 116 pages or so. I
have tried opening the report as acViewPreview but I am still running into
this issue.
The issue is the report states it is appending the files and locks up the
database during the append. I didn't see this issue discussed and so am
opening the can of worms here.
TIA,
Aaron
Check out Stephen Lebans site - it is the BEST for Access and images.
http://www.lebans.com/
--
Joe Fallon
Access MVP
"Aaron @ PASC" <aaron.kibbie@*N0SP@M*paschome.com> wrote in message
news:ei96Vk7TCHA.3936@tkmsftngp12...
Turn of the "Importing Image" dialog window via the registry keys as
outlined here:
http://www.mvps.org/access/api/api0038.htm
Make sure you do it for all Image types that you using that contain the
key.
Make sure your Hard Drive is defragmented.
You need 100's of MB's of HD space to spool a large report and lots of
virtual memory.
Use the Print Event to set the Image control's Picture property not the
Format event. The only caveat here is that you can not Autosize/Move the
Image control in the Print event.
Set the Image control's Picture prop to nothing prior to assigning a new
image to the prop.
I spent a couple of hours the other day experimenting on both Win98/A97
and Win2K/A2K systems. I tried everything I could think of to get the
sample Report on my site here not to fail without success. This is a 48
page report with 3 Jpegs per page. Even if you move the code to the
Print event it still will fail in Print Prview.
http://www.lebans.com/printfailures.htm
My Win2K system has 1.5GB ram and 70GB of free HD space but the Report
still fails. You can watch the resources increasing as you move through
the pages in Print Preview.
The WIn2K system will allow you to print the Report but I could not get
the WIn98 system to do the same.
Both systems will fail with the ERROR' Not enough free memory to update
the display" as you move through the pages in Print Preview. To me it
seems to be a problem in the Print Preview process, not the actual
spooling of the file to the print processor.
A nice surprise was that I could export to a Snapshot file on the
Win2K/A2K systems! Even moderate graphics on a small report would fail
on the Win98/A97 systems.
Next time I get a chance I am going to experiment with the different
Image types to see if this has any effect.
--
HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
"Joe Fallon" <jfal...@nospamtwcny.rr.com> wrote in message
news:urhvZR9TCHA.1668@tkmsftngp13...
--
Joe Fallon
Access MVP
"Stephen Lebans" <Stephe...@mvps.org> wrote in message
news:uT7GAdSUCHA.4008@tkmsftngp11...
- make sure you check that the the printcount or formatcount equals one when
running a subroutine that changes the .picture property. Otherwise it will
loop through unnecessarily.
Just add the following to the routine:
If Printcount = 1 then
' Do stuff here, like
img.Picture = FileName
End If
- (*much* more important): the reason for the failure seems to be a memory
leak in the image control. Through trial and error, I discovered that this
memory leak ONLY exists when the control has to read a non-BMP file such as
a JPEG. It does *not* happen with Windows Bitmaps.
Now of course no-one wants to waste all their HD space keeping all their
graphic in bloated BMP files. So the workaround is to have the OnPrint code
convert the file to a BMP and read that into the Image control. There are
several ways to do this. In my own database I use the excellent GflSDK
controls, available from http://www.xnview.com (free for non-commercial
use). You could also use the Imaging controls that come with Windows.
Basically, the OnPrint event converts the JPEG filename associated with that
record to a BMP file with a fixed name (e.g. Temp.BMP), sets the image box's
Picture property to Temp.BMP, forcing it to reread the file, and that's it.
Since adding this workaround, I've had ZERO out-of-resource or read failure
problems.
(I can post the code if anyone would find it useful)
HTH,
Bruce Rusk
"Stephen Lebans" <Stephe...@mvps.org> wrote in message
news:uT7GAdSUCHA.4008@tkmsftngp11...
For other formats, TIFF etc. then your suggested method is definately
the way to go!
Could you send me an MDB with your code. I'd like to document it as part
of the process and an obviously viable solution.
Great work Bruce!
--
HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
"Bruce Rusk" <hom...@hatespam.ucla.edu> wrote in message
news:epCVsRgUCHA.3824@tkmsftngp12...
It's a bit of a complicated database, but what's relevant is the following
code from the report. It depends on having the GflAx control available, but
you could convert the file another way. It also depends on there being a
field from the underlying query called .FileName that contains the name of
the image file (jpeg in this case).
Bruce
***************************************************
Option Compare Database
Option Explicit
Private Const conFirstPass As Long = 1
Private ctlCharImg As Access.Image
Dim ocxGflAx As Object
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If FormatCount = conFirstPass Then
ctlCharImg.Picture = vbNullString
End If
End Sub
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
'On Error GoTo Print_Error
With Me
If PrintCount = conFirstPass Then
If Len(Nz(.FileName, vbNullString)) > 2 Then
TIF2BMP ocxGflAx, .FileName, gstrTempBMP, True
ctlCharImg.Picture = gstrTempBMP
End If
End If
End With
Exit Sub
Print_Error:
If Err.Number = 2220 Or Err.Number = 2114 Then
' File conversion errors
Err.Clear
ctlCharImg.Picture = vbNullString
Exit Sub
Else
MsgBox Err.Number & " - " & Err.Description, vbOKOnly + vbCritical,
conAppName
Err.Clear
Resume Next
End If
End Sub
Private Sub Report_Close()
Set ocxGflAx = Nothing
End Sub
Private Sub Report_Open(Cancel As Integer)
Set ctlCharImg = Me!imgSourceChar
Set ocxGflAx = CreateObject("gflax170.gflax")
With ocxGflAx
.EnableLZW = True
.SaveFormat = 4 ' BMP
End With
End Sub
*****************************************************
"Stephen Lebans" <Stephe...@mvps.org> wrote in message
news:#iCBYMhUCHA.2928@tkmsftngp13...
Special thanks to Bruce who's workaround is splendid and Stephen who's
continued contributions are invaluable.
Aaron
Unfortunately Acess still runs out of resources when you page back and
forth through Print Preview.
I plan to spend some time onthis issue shortly.
Here is the code I use to convert any Jpeg, Gif, or Metafile into a BMP.
Rather than using one of my API solutions I have cheated and set a
Reference to Standard OLE Types type library in order to get at the
SAVETODISK method. But no ActiveX controls are required
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
Private ctr As Long
ctr = ctr + 1
Select Case ctr
Case 1
Me.Image10.Picture = CreateBitmapFile("C:\A.jpg")
Case 2
Me.Image10.Picture = CreateBitmapFile("C:\b.jpg")
Case 3
Me.Image10.Picture = CreateBitmapFile("C:\c.jpg")
ctr = 0
Case Else
ctr = 0
End Select
End Sub
Private Sub Report_Open(Cancel As Integer)
ctr = 0
End Sub
Private Function CreateBitmapFile(fname As String) As String
Dim obj As Object
Set obj = LoadPicture(fname)
If Not IsNull(obj) Then
SavePicture obj, "C:\SL11-52"
DoEvents
End If
CreateBitmapFile = "C:\SL11-52"
Set obj = Nothing
End Function
--
HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
"Bruce Rusk" <hom...@hatespam.ucla.edu> wrote in message
news:O0DMcElUCHA.3740@tkmsftngp08...