no photo found... what now?

  • Thread starter Jean-Paul De Winter
  • Start date
J

Jean-Paul De Winter

I wrote following code:

Private Sub Form_Current()
If IsNull(Me!foto) = False Then
Me![fotoken].Picture = Me![foto]
Else
Me![fotoken].Picture = "c:\DBI\logo.jpg"
End If
End Sub

This works just great now but, I get an errormessage when no photo is
found in the corresponding path.
Could you please explain what I should write to avoid this?
Maybe something like setting the image.visible to false or whatever.

Thanks
JP
 
D

Douglas J. Steele

Assuming that Me![foto] contains the path to the (missing) photo, try:

Private Sub Form_Current()
If IsNull(Me!foto) = False Then
If Len(Me![foto]) > 0 Then
Me![fotoken].Picture = Me![foto]
Else
Me![fotoken].Picture = "c:\DBI\logo.jpg"
End If
Else
Me![fotoken].Picture = "c:\DBI\logo.jpg"
End If
End Sub
 
J

Jean-Paul De Winter

Douglas said:
Assuming that Me![foto] contains the path to the (missing) photo, try:

Private Sub Form_Current()
If IsNull(Me!foto) = False Then
If Len(Me![foto]) > 0 Then
Me![fotoken].Picture = Me![foto]
Else
Me![fotoken].Picture = "c:\DBI\logo.jpg"
End If
Else
Me![fotoken].Picture = "c:\DBI\logo.jpg"
End If
End Sub
I don't think this will work...
If len(Me!foto)> 0 but the path to to the photo is wrong so the photo
can't be found (deleted as ex.) what then?
Thnaks
 
D

Douglas J. Steele

Sorry: typing too quickly.

Rather than Len(Me![foto]) > 0, it should be Len(Dir(Me![foto])) > 0

The Dir function returns the name of the file (no path) if the file exists,
or an empty string if it doesn't.

My apologies for the confusion.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Jean-Paul De Winter said:
Douglas said:
Assuming that Me![foto] contains the path to the (missing) photo, try:

Private Sub Form_Current()
If IsNull(Me!foto) = False Then
If Len(Me![foto]) > 0 Then
Me![fotoken].Picture = Me![foto]
Else
Me![fotoken].Picture = "c:\DBI\logo.jpg"
End If
Else
Me![fotoken].Picture = "c:\DBI\logo.jpg"
End If
End Sub
I don't think this will work...
If len(Me!foto)> 0 but the path to to the photo is wrong so the photo
can't be found (deleted as ex.) what then?
Thnaks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top