Photos in forms.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am having a problem with a little bit of coding. I have a database for
contractors with a Form for viewing info on the contractors as well as their
photos. Not all photos have been taken, so I want the form to display a
graphic indicating that the photo is missing (NoPix.JPG in the code). All is
working in that the graphic is displaying when there is no photo. The problem
is that the Form displays an existing photo for a second then replaces it
with the NoPix.JPG. :(
I am incuding the code. Any ideas?
Thanking you in advance....
 
Thronz said:
I am having a problem with a little bit of coding. I have a database for
contractors with a Form for viewing info on the contractors as well as their
photos. Not all photos have been taken, so I want the form to display a
graphic indicating that the photo is missing (NoPix.JPG in the code). All is
working in that the graphic is displaying when there is no photo. The problem
is that the Form displays an existing photo for a second then replaces it
with the NoPix.JPG. :(
I am incuding the code. Any ideas?
Thanking you in advance....

Private Sub Form_Current()

Set db = CurrentDb
filename = db.Name
Pathname = Mid(filename, 1, Len(filename) - Len(Dir(filename)))

On Error GoTo PictureNotAvailable

Me.imgPHOTO.Picture = Pathname & Me.PHOTO

PictureNotAvailable:
Me.imgPHOTO.Picture = Pathname & "NoPix.JPG"


End Sub


OOPS, I forgot the code....
 
Thronz said:
I am having a problem with a little bit of coding. I have a database
for contractors with a Form for viewing info on the contractors as
well as their photos. Not all photos have been taken, so I want the
form to display a graphic indicating that the photo is missing
(NoPix.JPG in the code). All is working in that the graphic is
displaying when there is no photo. The problem is that the Form
displays an existing photo for a second then replaces it with the
NoPix.JPG. :(
I am incuding the code. Any ideas?
Thanking you in advance....

I use the Dir command to run through a folder, check for duplicates and
store new paths in both "pictureloc" and the description field. Then I can
go back and change the description.

This code in OnCurrent sets the picture if there is one and uses another
default picture if there is nothing there.
Be sure and use some sort of a default as the last picture stays in place if
you don't.

Private Sub Form_Current()
On Error Resume Next
If Nz(Me!pictureloc, 0) = 0 Then
Me!pictureloc = "d:\volpics\Maltesecross.gif"
End If
Me![Image24].Picture = Me![pictureloc]

End Sub
 
Thronz heeft ons zojuist aangekondigd :
Private Sub Form_Current()

Set db = CurrentDb
filename = db.Name
Pathname = Mid(filename, 1, Len(filename) - Len(Dir(filename)))

On Error GoTo PictureNotAvailable

Me.imgPHOTO.Picture = Pathname & Me.PHOTO

Exit Sub
PictureNotAvailable:
Me.imgPHOTO.Picture = Pathname & "NoPix.JPG"


End Sub


OOPS, I forgot the code....

Add the exit sub (as above)
 
What is the Nz in the
If Nz(Me!pictureloc, 0) = 0 Then
section of code? I tried this and am now getting an error that the file is
missing when there is no photo...

Mike Painter said:
Thronz said:
I am having a problem with a little bit of coding. I have a database
for contractors with a Form for viewing info on the contractors as
well as their photos. Not all photos have been taken, so I want the
form to display a graphic indicating that the photo is missing
(NoPix.JPG in the code). All is working in that the graphic is
displaying when there is no photo. The problem is that the Form
displays an existing photo for a second then replaces it with the
NoPix.JPG. :(
I am incuding the code. Any ideas?
Thanking you in advance....

I use the Dir command to run through a folder, check for duplicates and
store new paths in both "pictureloc" and the description field. Then I can
go back and change the description.

This code in OnCurrent sets the picture if there is one and uses another
default picture if there is nothing there.
Be sure and use some sort of a default as the last picture stays in place if
you don't.

Private Sub Form_Current()
On Error Resume Next
If Nz(Me!pictureloc, 0) = 0 Then
Me!pictureloc = "d:\volpics\Maltesecross.gif"
End If
Me![Image24].Picture = Me![pictureloc]

End Sub
 
Back
Top