Adding Photos to employee database

Is it possible to add a true or false statement to the coding for this? Currently, if Access can't find the individual's picture in the folder that the path is pointing to it displays the last picture that was found. Can I add a true/false statement that tells Access if file not found open default "NO Image.jpg"?

This is the current code:

Code:
Private Sub Form_Current()
    On Error Resume Next
    Me![imgImageFrame].Picture = Me![strImagePath]
End Sub
Private Sub strImagePath_AfterUpdate()
    On Error Resume Next
    Me![imgImageFrame].Picture = Me![strImagePath]
End Sub
[Code/]
 
It is a single form. This form contains each individuals information and photo. When going to next record if the picture is not found Access uses the last found picture. I'd like it to default to the NO Image Jpg
 
You could also do a Function like this:

Code:
Function GetPicture()
    With CodeContextObject
        If Dir(.[strImagePath]) <> Empty Then
            .[imgImageFrame].Visible = True
            .[imgImageFrame].Picture = .[strImagePath]
        Else
            .[imgImageFrame].Visible = False
        End If
    End With
End Function

If you have Access 2007 your Control Source for imgImageFrame=strImagePath. I have always done used VB method but the later certainly works for Continuous Forms.

Simon
 
Is this code on Before update, After Update? Where would I put this code?

The current code is on After Update
 
VBinet, I appreciate all of your help but I have no idea where that code would go in my current sub. I DO NOT know how to write code or how it is structured. I can copy code and put it where it needs to go and that's about the extent of my code knowledge.

Where would this code go?
=Nz([strImagePath], "C:\sladetroityer\NoImage.bmp")
 
I think I remember from one of your other threads you mentioned that you use Access 2007 or 2010, so put the code in the Control Source property of the image control.
 
I mean, did you comment out any other code that interfers with the Image Control itself?

Does it work with just [strImagePath] set as the Control Source?
 
Currently It works but with the exception that when Access doesn't find the jpg it reverts back to last found picture. Therefore pictures of the wrong person are showing up.

I have code like this on AfterUpdate:

Private Sub Form_Current()
On Error Resume Next
Me![imgImageFrame].Picture = Me![strImagePath]
End Sub
Private Sub strImagePath_AfterUpdate()
On Error Resume Next
Me![imgImageFrame].Picture = Me![strImagePath]
End Sub
 
First of all, that's not the After Update event. It's the Current event.

Secondly, I did mention you should remove any code that interfers with the Image Control.
 
I removed the afterupdate and on current code and the no pictures come up only the No Image file is displyed.
 
With the Nz() code?

Copy and paste the path to the NoImage image into a web browser. See if it works.
 
The no Image comes up for everyone but most people have pictures so it's working properly.
 

Users who are viewing this thread

Back
Top Bottom