Photos in forms.

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....
 
G

Guest

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....
 
M

Mike Painter

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
 
G

Gijs Beukenoot

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)
 
G

Guest

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
 

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