R
ridders
For a school database with about 900 classes, I have created a report for
each class, each showing up to 35 thumbnails of pupil photos! Each image is
displayed in a frame linked to the image path. Where no photo is available a
default image is shown instead. All works OK though attempting to do a batch
print of all the reports causes access to crash. However, I have to use
absolute filepaths for both pupil photos & the default image to do so even
though the code should work with a relative path. All forms work fine with
relative or UNC paths as well.
The code used is:
****************************************************
Option Compare Database
Option Explicit
Function IsRelative(fName As String) As Boolean
' Return false if the file name contains a drive or UNC path
IsRelative = (InStr(1, fName, ":") = 0) And (InStr(1, fName, "\\") = 0)
End Function
Function setImagePath()
Dim res As Boolean
Dim fName As String
Dim path As String
Dim strImagePath As String
path = CurrentProject.path
On Error GoTo PictureNotAvailable
If Not IsNull(Me!ImagePath) Then
res = IsRelative(Me!ImagePath)
fName = Me![ImagePath]
If (res = True) Then
fName = path & "\" & fName
End If
strImagePath = Me.ImagePath
Me.ImageFrame.Picture = strImagePath
Exit Function
PictureNotAvailable:
'res = IsRelative(Me!ImagePath)
' fName = Me![ImagePath]
'If (res = True) Then
' fName = path & "\" & fName
' End If
strImagePath = "D:\Documents and Settings\Colin\My Documents\Reports
Manager\RMP4\Photos\NoPhoto.bmp"
Me.ImageFrame.Picture = strImagePath
End If
End Function
Private Sub Report_NoData(Cancel As Integer)
MsgBox "No data found! Closing report."
Cancel = True
End Sub
*******************************************************
I've not yet tried using a UNC path for the report though this is what I
intend to use once it goes on the network.
Any ideas?
ridders
each class, each showing up to 35 thumbnails of pupil photos! Each image is
displayed in a frame linked to the image path. Where no photo is available a
default image is shown instead. All works OK though attempting to do a batch
print of all the reports causes access to crash. However, I have to use
absolute filepaths for both pupil photos & the default image to do so even
though the code should work with a relative path. All forms work fine with
relative or UNC paths as well.
The code used is:
****************************************************
Option Compare Database
Option Explicit
Function IsRelative(fName As String) As Boolean
' Return false if the file name contains a drive or UNC path
IsRelative = (InStr(1, fName, ":") = 0) And (InStr(1, fName, "\\") = 0)
End Function
Function setImagePath()
Dim res As Boolean
Dim fName As String
Dim path As String
Dim strImagePath As String
path = CurrentProject.path
On Error GoTo PictureNotAvailable
If Not IsNull(Me!ImagePath) Then
res = IsRelative(Me!ImagePath)
fName = Me![ImagePath]
If (res = True) Then
fName = path & "\" & fName
End If
strImagePath = Me.ImagePath
Me.ImageFrame.Picture = strImagePath
Exit Function
PictureNotAvailable:
'res = IsRelative(Me!ImagePath)
' fName = Me![ImagePath]
'If (res = True) Then
' fName = path & "\" & fName
' End If
strImagePath = "D:\Documents and Settings\Colin\My Documents\Reports
Manager\RMP4\Photos\NoPhoto.bmp"
Me.ImageFrame.Picture = strImagePath
End If
End Function
Private Sub Report_NoData(Cancel As Integer)
MsgBox "No data found! Closing report."
Cancel = True
End Sub
*******************************************************
I've not yet tried using a UNC path for the report though this is what I
intend to use once it goes on the network.
Any ideas?
ridders