I am using Access 97. I have a report that has a picture associated with each record. The pictures are stored in a separate directory and the path is found with the OnFormat event. The picture load fine if I cycle throught the records. However, if I try to print out the report for more than 30 records, the report crashes. I get an error message that states that the picture cannot be found. I checked the directory and the pictures exist and the picture will show up if I scroll through the report one record at a time. I also have noticed that access loads two pictures every time that I go to the next record. It loads the current record and the next record, even though the report only shows the current picture. The following is the code that I am using to link the pictures. Any help would be greatly appreciated.
thanks,
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
Dim txtLocation As Integer
Dim txtLocName As String
Set MyDB = CurrentDb()
Set myLoc = MyDB.OpenRecordset("tblFileLocations", dbOpenTable)
txtLocation = [Forms]![frmSearch_Reports]![lstSelectALocation].Value
txtLocName = DLookup("[LocationDesc]", "tblLocationDesc", "[LocationID] = " & txtLocation)
myPath = myLoc!PictureLocation & txtLocName & "\"
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
thanks,
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
Dim txtLocation As Integer
Dim txtLocName As String
Set MyDB = CurrentDb()
Set myLoc = MyDB.OpenRecordset("tblFileLocations", dbOpenTable)
txtLocation = [Forms]![frmSearch_Reports]![lstSelectALocation].Value
txtLocName = DLookup("[LocationDesc]", "tblLocationDesc", "[LocationID] = " & txtLocation)
myPath = myLoc!PictureLocation & txtLocName & "\"
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