I am using Access 97. I have a report that has an image control in it. I have the pictures stored in a directory on a network drive. All the pics are jpegs. I am trying to get the report to load more efficiently. I have the following code in the On Format event:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim MyDB As Database, myLoc As Recordset
Dim myPath, myFile, strSource As String
Set MyDB = CurrentDb()
Set myLoc = MyDB.OpenRecordset("tblFileLocations", dbOpenTable)
myPath = myLoc!PictureLocation & Me.LocationDesc.Value & "\"
myFile = Dir(myPath & Me.PWCTankID.Value & "*.jpg"
' Retrieve the first entry.
If myFile = "" Then
Me.imgTank.Visible = False
Else
Me.imgTank.Visible = True
Me.imgTank.Picture = myPath & myFile
End If
myLoc.close
End Sub
The report is based on a query. Depending on the query criteria, there could be over 100 records in the report. When I try to print the report (or just go to the last record), the report gets a run-time error 2114 after about 40 records. The error states that the file format is not valid. I have checked all of the pics and they all open fine in windows explorer. However, if the report has less than 40 records, there is no error. It takes about 5 minutes to get through all of the records and send the report to the printer, because access is loading so many pictures. Another problem is that when the report is changing records, two pictures are always loaded (the next two pictures). I cannot figure out why it always loads two pics. Any help would be greatly appreciated.
Jeff Weisman
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim MyDB As Database, myLoc As Recordset
Dim myPath, myFile, strSource As String
Set MyDB = CurrentDb()
Set myLoc = MyDB.OpenRecordset("tblFileLocations", dbOpenTable)
myPath = myLoc!PictureLocation & Me.LocationDesc.Value & "\"
myFile = Dir(myPath & Me.PWCTankID.Value & "*.jpg"
If myFile = "" Then
Me.imgTank.Visible = False
Else
Me.imgTank.Visible = True
Me.imgTank.Picture = myPath & myFile
End If
myLoc.close
End Sub
The report is based on a query. Depending on the query criteria, there could be over 100 records in the report. When I try to print the report (or just go to the last record), the report gets a run-time error 2114 after about 40 records. The error states that the file format is not valid. I have checked all of the pics and they all open fine in windows explorer. However, if the report has less than 40 records, there is no error. It takes about 5 minutes to get through all of the records and send the report to the printer, because access is loading so many pictures. Another problem is that when the report is changing records, two pictures are always loaded (the next two pictures). I cannot figure out why it always loads two pics. Any help would be greatly appreciated.
Jeff Weisman