I've got a database with 1400 records in it. Each record is associated with a .jpg file whose file name is the same as the primary key of the database. These .jpg files are really small (about 30k/picture) vector drawings from Macromedia Freehand.
Using some code (see below) I got from microsoft.com I can display the drawings on individual report and form pages very effectively.
The problem comes with a report that is five pages per primary key. The second page is the drawing and it looks like it is working really well until it gets to record 1170 when I get a message "2114 Microsoft Office Access doesn't support the format of the file C:3004512345.jpg or the file is too large. Try converting the file to BMP or GIF format". Then I have to say "OK" on that record and each of the next 5,000 records to get to the end and display the report (I did it once to see if it would really make me hit that button 4,000 times, after that I ALT-CNTL-DEL out and crash Access).
The report opens, and you can step through the first few hundred records very quickly. Does anyone see anything in the code that could prevent this memory contamination?
Thanks
David
Using some code (see below) I got from microsoft.com I can display the drawings on individual report and form pages very effectively.
The problem comes with a report that is five pages per primary key. The second page is the drawing and it looks like it is working really well until it gets to record 1170 when I get a message "2114 Microsoft Office Access doesn't support the format of the file C:3004512345.jpg or the file is too large. Try converting the file to BMP or GIF format". Then I have to say "OK" on that record and each of the next 5,000 records to get to the end and display the report (I did it once to see if it would really make me hit that button 4,000 times, after that I ALT-CNTL-DEL out and crash Access).
The report opens, and you can step through the first few hundred records very quickly. Does anyone see anything in the code that could prevent this memory contamination?
Thanks
David
Code:
Option Compare Database
Option Explicit
Public Function DisplayImage(ctlImageControl As Control, strImagePath As Variant) As String
On Error GoTo Err_DisplayImage
Dim strResult As String
Dim strDatabasePath As String
Dim intSlashLocation As Integer
With ctlImageControl
If IsNull(strImagePath) Then
.Visible = False
strResult = ""
Else
If InStr(1, strImagePath, "\") = 0 Then
' Path is relative
strDatabasePath = CurrentProject.FullName
intSlashLocation = InStrRev(strDatabasePath, "\", Len(strDatabasePath))
strDatabasePath = Left(strDatabasePath, intSlashLocation)
strImagePath = strDatabasePath & strImagePath
End If
.Visible = True
.Picture = strImagePath
strResult = "Image found and displayed."
End If
End With
Exit_DisplayImage:
DisplayImage = strResult
Exit Function
Err_DisplayImage:
Select Case Err.Number
Case 2220 ' Can't find the picture.
ctlImageControl.Visible = False
strResult = "Can't find image in the specified name."
Resume Exit_DisplayImage:
Case Else ' Some other error.
MsgBox Err.Number & " " & Err.Description
strResult = "An error occurred displaying image."
Resume Exit_DisplayImage:
End Select
End Function
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
Dim outFilename As String
outFilename = "c:\BP_Spcc\CombinedData\" + API + ".jpg"
Me!txtImageNote = DisplayImage(Me!ImageFrame, outFilename)
End Sub