I have a working code that loads multiple pictures into a grid on a form (I use it as a seating chart for my students). I currently have the record source property for the form set and as expected, when I print, I get redundant copies of the form for each record in the recordset. How do I re-write the code to leave the form's record source blank yet still open the query (qryDeptStudents) and get a nice set of orderly pictures? I would like to do this in a report as well. Any suggestions?
Also, I am getting numerous error code 2220s even though all images load every time I run the code (I get some error code 0s, too). I had to turn off the error line to display a preselected image when the appropriate image for a student's record was missing. Any ideas here as well?
Private Sub Form_Load()
'Set error trap
On Error Resume Next
Dim strPath As String
Dim db As Object
Dim rst As DAO.Recordset
Set rst = Me.RecordsetClone
If .RecordCount Then
Do Until .EOF
'When the last record is reached the code stops
Me.Bookmark = .Bookmark
' Assign ID as path for images
strPath = Me.ID
'Establish path for existing images and default path for missing immages
Debug.Print "Error code: " & Err
'If Err <> 0 Then
'strPath = CurrentProject.Path & "\Resources\Images\ths.png"
strPath = CurrentProject.Path & "\Resources\Images\Students\" & strPath & ".jpg"
'Load picture and name to form
Me.Controls("Seat" & Me.Chair).Picture = UCase(strPath)
Me.Controls("Student" & Me.Chair) = Me.Last & ", " & Me.First
strPath = ""
Set rst = Nothing