Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Load a picture in Access form

Access Howto:

How to Load a picture in Access form

by  DougP  Posted    (Edited  )
What this does...
It loads a picture ie .jpg or .gif or .bmp into an Image control on the form. So as you navigate through the records it automatically loads a picture from the hard drive.
Note: It might be slow if the picture is large or you have a slow machine. A Pentium II or better should be fine.
Benefits: Can have thousands/10's of thousands of pictures and does not Bloat database. Becasue no pictures are inside the database they are left on the hard drive.

Steps:
1. Add an "Image" control to the form.
Follow the prompts and load a picture of the type you will be using.
2. Open the properties of the image and remove the picture.
3. Put this code in the forms On_current event
---------------------------------------
Private Sub Form_Current()
If Me![ID] <> 0 Then
Me!Image14.Picture = "p:\ViewPhotos\Photos\" &amp; Me![ID] &amp; ".jpg"
Label20.Caption = "File: " &amp; " p:\ViewPhotos\Photos\" &amp; Me![ID] &amp; ".jpg"
End If
End Sub
----------------------------------
The Label20 simply shows the path of the picture for troubleshooting purposes.

Now in my example the picture name was the same as the ID on the form. So when ID 23454 was showing on the form, it loaded 23454.jpg into the image.
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top