Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / December 2005

Tip: Looking for answers? Try searching our database.

Display contact photos

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Eric F - 10 Dec 2005 03:20 GMT
Can someone shed some light on an easy way to display contact photos for
each contact that contains a picture on a network drive. I would like to see
some code that will display the picture using the a path. The pictures are
named the same as the ContactID. I.e. 1234.jpg  (1234 = ContactID number).
Any thoughts would  be great.

TY
Eric
jonefer - 10 Dec 2005 05:17 GMT
Yes that can be done quite easily.
Use the "Image" tool that can be found on the toolbar...

1) Drag it onto you form, to the size you want...
2) just humor the request for a picture and put a dummy one in with the
browser
(preferrably a jpeg or bitmap, stay away from GIF)
3) Name your Image something better than Image1 (imgContactPhoto)...
4) quite literally your code will be
imageContactPhoto.picture = "c:\photos\contact1.jpg"

insert this code into the current event of the form.

Voila!  The photo in the path for the record will bring up the photo  
and your database won't be croweded with anything but a text reference to a
path.

Hope you are successful.  Let me know.  I have more tricks, but let me know
when you get this working!

> Can someone shed some light on an easy way to display contact photos for
> each contact that contains a picture on a network drive. I would like to see
[quoted text clipped - 4 lines]
> TY
> Eric
Eric F - 10 Dec 2005 14:42 GMT
Thanks for the quick reply. I think you had intentions of puting some code
in this email? I am still in need of a solution to have the picture change
when I change the contact or just show a blank if no picture is on file. Any
help would be great. Thank you.

> Yes that can be done quite easily.
> Use the "Image" tool that can be found on the toolbar...
[quoted text clipped - 29 lines]
>> TY
>> Eric
jonefer - 10 Dec 2005 16:17 GMT
In the form's "Current" event

Place the following code  (This is assuming you have placed the image holder
and named it something like ContactPic - oh and also assuming you have a
ContactDetail form with all their information that you want to relate this to)

Private Sub Form_Current
dim PathToPhoto as string
dim ContactPhoto as string
PathToPhoto = "D:\MyContactPhotos....wherever your path is"
ConactPhoto = Me.ContactID & ".jpg"
'(try to be consistent in whatever format you decide)

If len(PathToPhoto & "\" & Me.ContactID & ".jpg") <> 0 then
   ContactPic.Picture =  ContactPhoto
Else
   ContactPic.Picture = ""  

'(Or you could have a picture of your company logo here "CompanyLogo.jpg")
End If

This process will make it so all you have to do, is acquire that photo from
your contact, and put it in the folder named ContactID.jpg (for each
different Contact)
Example 434.jpg, 435.jpg  etc..

When you delete their photo, the program will automatically display the
CompanyLogo.jpg

This can be tweaked a little more, but should suffice.
When you test it after you have acquired at least 2 or 3 photos, try moving
through each contact record - You will notice the contacts picture changing
for each contact if you PageDown or click your 'Next' button through your
Details form.

> Thanks for the quick reply. I think you had intentions of puting some code
> in this email? I am still in need of a solution to have the picture change
[quoted text clipped - 34 lines]
> >> TY
> >> Eric
Eric F - 11 Dec 2005 00:37 GMT
This works great...Thanks. The only problem I am having is I get an error if
I don't have a pic for all the contacts. Is there some code I can put in to
show nothing is a contact has no pic?

> In the form's "Current" event
>
[quoted text clipped - 80 lines]
>> >> TY
>> >> Eric
Eric F - 11 Dec 2005 00:37 GMT
This works great...Thanks. The only problem I am having is I get an error if
I don't have a pic for all the contacts. Is there some code I can put in to
show nothing is a contact has no pic?

> In the form's "Current" event
>
[quoted text clipped - 80 lines]
>> >> TY
>> >> Eric
jonefer - 11 Dec 2005 08:43 GMT
Try the following...
Create a picture called "Blank.jpg" with your favorite photo editor
(photoshop etc.)
For the "else" portion of the IF statement.  It could be plain gray, white,
or a company logo.
I'm figuring this should be enough to prevent an error, but
I even added error handling just in case -
(look at the error number you receive when you get this error and use it
below)

Then use the following, in your current event:
Private Sub Form_Current
On Error GoTo EH
If len(PathToPhoto & "\" & Me.ContactID & ".jpg") <> 0 then
   ContactPic.Picture =  ContactPhoto
Else
   ContactPic.Picture =  PathToPhoto & "\" & "Blank.jpg"
End If

Exit Sub
EH:
Select Case Err
case 52,62 '(or whatever number you see)
ContactPic.Picture =  PathToPhoto & "\" & "Blank.jpg"
msgbox "No picture available"
end select
End Sub

Just keep playing around with this.. you'll get it soon.

> This works great...Thanks. The only problem I am having is I get an error if
> I don't have a pic for all the contacts. Is there some code I can put in to
[quoted text clipped - 84 lines]
> >> >> TY
> >> >> Eric
Eric F - 12 Dec 2005 16:22 GMT
Good morning,

I first want to thank you for helping me on this. It is almost working 100%.
I have one more issue... Upon opening the project the pictures will not
display, almost like it has lost connection with the path. The pictures are
contained on a network drive. If I go into the properties of the picture box
and click on the picture path it will work. But of course doesnt when I have
closed and reopened the DB. Below is the code I am using.

Private Sub Form_Current()
On Error GoTo Err_NoPic
Dim PathToPhoto As String
Dim ContactPhoto As String
PathToPhoto = "I:\NAIOP_Website\images\Members"
ContactPhoto = Me.ContactID & ".jpg"

If Len(PathToPhoto & "\" & Me.ContactID & ".jpg") <> 0 Then
   ContactPic.Picture = ContactPhoto
Else
   ContactPic.Picture = "I:\NAIOP_Website\images\Members\nopic.jpg"
End If

Err_NoPic:
   Select Case Err
   Case 2220
   ContactPic.Picture = "I:\NAIOP_Website\images\Members\nopic.jpg"
   End Select
End Sub

> Try the following...
> Create a picture called "Blank.jpg" with your favorite photo editor
[quoted text clipped - 128 lines]
>> >> >> TY
>> >> >> Eric
jonefer - 12 Dec 2005 17:52 GMT
Good morning.  You caught me on the way to work. I'm glad it's almost 100%
My application is similar, but when I answered your questions, I tried to
improve on my design.

Just curious.  After you open, if you move to the next record does a picture
display?
If so, try one more thing and if that doesn't work, I'll see if I can look
at it tonight.

in your "Load" event put the following line:

call form_current

This will call the same code when the form loads.

and the current event will take over for every subsequent record you look at.
(I noticed that I did this in my application, but I thought it was redundant
)- I assumed the current event takes place in the Load Event as well.  So try
this... again if it doesn't work, I'll help you until it does!

> Good morning,
>
[quoted text clipped - 157 lines]
> >> >> >> TY
> >> >> >> Eric
Eric F - 12 Dec 2005 20:34 GMT
This may also shed some light on the problem. I can see an error box flash
and clearly there is a nopic.jpg in the spot. So I know it is calling the
right path. Problem must lie in the link from the Picture box. I have tried
leaving the pic box link to (none) and also with the path to no avail.

Thanks again.

> Good morning.  You caught me on the way to work. I'm glad it's almost 100%
> My application is similar, but when I answered your questions, I tried to
[quoted text clipped - 199 lines]
>> >> >> >> TY
>> >> >> >> Eric
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.