I have a report that displays pictures from a picture path - but I need to adjust the code so that it skips records that don't have a valid picture path - how do i do this?
Make sure that you have the object PicturePath in the Detail Section. It can be invisible but it must be there. Put the following code into the OnFormat event procedure of the Detail Section of the report: [/code]
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
On Error GoTo Detail_Error
Dim vFileLength as long
vFileLength = FileLen(Me![PicturePath])
Detail_Exit:
Exit Sub
Detail_Error:
DoCmd.CancelEvent
GoTo Detail_Exit
End Sub
[/code]
This tests for the validity of the path by trying to return the size of the file. If it cannot find it then it will error out at which time the error trap will Cancel the event. If it find the file and returns a value then it will continue through the Exit_Sub and allow for Formatting of the Detail Section.
Kultx, I have been trying to get the pictures to picture on the report without success. I get black image boxes. How did you get the report to read the path. Thanks in advance.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.