A
AccessNewbie
Here is the scenario: DB contains an image object on a form. The image
that appears is a photo of a cub scout, with the name of the image set
to match the unique "ScoutID" of the individual. Everything works
fine, until the next time I open the form, when I get a runtime error
2220: "Microsoft Office Access can't open the file 'name.jpg.'
If I delete the image object on the form, replace it with exactly the
same object, named the same, it works fine. Then, next time I open the
form, again with the error.
The code behind the image object:
Private Sub Form_Current()
Dim sFileName As String
sFileName = "C:\Documents and Settings\Mr. Admin\My Documents\My
Pictures\Cub Scouts\" & Me.ScoutID & ".jpg"
' See if this photo exists
' Returns a zero length string if file does not exist
sFileName = Dir(sFileName)
If Len(sFileName & vbNullString) = 0 Then
' Load "Not Available" Photo
Me.ImagePhoto.Picture = "C:\Documents and Settings\Mr. Admin\My
Documents\My Pictures\Cub Scouts\NotAvailable.jpg"
Else
' Load the matching Photo for this ScoutID
Me.ImagePhoto.Picture = sFileName
End If
End Sub
Can anyone tell what's going on here? I actually have the same problem
in two databases, both using images as described.
Thanks for your suggestions,
David
PS: I know little about VB coding; I got the code above from an old
discussion thread somewhere.
that appears is a photo of a cub scout, with the name of the image set
to match the unique "ScoutID" of the individual. Everything works
fine, until the next time I open the form, when I get a runtime error
2220: "Microsoft Office Access can't open the file 'name.jpg.'
If I delete the image object on the form, replace it with exactly the
same object, named the same, it works fine. Then, next time I open the
form, again with the error.
The code behind the image object:
Private Sub Form_Current()
Dim sFileName As String
sFileName = "C:\Documents and Settings\Mr. Admin\My Documents\My
Pictures\Cub Scouts\" & Me.ScoutID & ".jpg"
' See if this photo exists
' Returns a zero length string if file does not exist
sFileName = Dir(sFileName)
If Len(sFileName & vbNullString) = 0 Then
' Load "Not Available" Photo
Me.ImagePhoto.Picture = "C:\Documents and Settings\Mr. Admin\My
Documents\My Pictures\Cub Scouts\NotAvailable.jpg"
Else
' Load the matching Photo for this ScoutID
Me.ImagePhoto.Picture = sFileName
End If
End Sub
Can anyone tell what's going on here? I actually have the same problem
in two databases, both using images as described.
Thanks for your suggestions,
David
PS: I know little about VB coding; I got the code above from an old
discussion thread somewhere.