Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Loading Pics in a report --run-time error

Status
Not open for further replies.

jweisman

Technical User
May 1, 2002
26
0
0
US
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
 
Your query probably has ODBC timeout 60 sec or something.
Open Query Design View and right/click Property.
Last Property Item is ODBC timeout - make it nothing. Just leave blank and see

Hope it'll work

TIA
 
I just tried this, but I still got the run-time error.
 
OK, if main Query uses other queries - all suppose to be set as ODBC timeout = blank.
Yet, compact database, you know Access does use old setting untill it is compacted/repaired.

Try it, what do you get to lose ?.. untill someone else will step in and may actually help :)
TIA
 
The main query does not use any other queries.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top