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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Linking pictures to files

Status
Not open for further replies.

mstrbfg

MIS
Jan 31, 2003
12
0
0
US
I'm wondering if someone can help me. I created a form in Microsoft Access. This form has street addresses. I want to be able to link a photo to the addreses. For example. If i search a street (ie 10 elm st) it will show the info for that address and i want to be able to click a field that show the picture name and the pic will be displayed

there will be alot of pictures.
in essence i want the photos to be linked to the database

Can this be done???
 
Take a look at the Northwind database.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Private Sub Form_Current()

Image3.Picture = Filename

End Sub

Image3 is an Image Control - set it up as Linked. Put any picture in it, and then in the properties grid delete the picture property.

Filename is a field in the underlying table, and for simplicity could be a visible or invisible textbox on your form.

Warnining - this will not work with Continuous Forms, only Single Forms.
 
I under the general concept of your reply. can you outline the steps i would need to do so that i can implement this
 
Assuming the table to which your form is bound has a field called Filename.

With your form in design view ...

Add an Image Control from the Toolbox. As soon as you release the mouse, the OpenFile dialog appears. Locate a picture file on your hard disk. (The dialog boxx is preset you only show you picture files). As soon as you have selected a file and clicked OK, the dialog box will close.

In the properties window, select the Format Tab.

Picture Type (second item in list) will probably say embedded change this to linked, by clicking in the drop down arrow on the right hand side.

Next the filename of the picture you selected will be in the top item Picture. Delete this. A warning dialog might appear, say yes you do want to delete the picture.

You now have an empty frame.

At the top of the property window is a combo(drop down)box which should show Image9 (or whatever the name of the Image Control is). Click the arrow and scroll down to Form.

Click on the Event Tab, the top ost Event in the list is On Current. DoubleClick in the blank space to the right and [Event Procedure] will appear. Click on the button on the far right with ... on it and you will be taken to the vba window. You should see something like this:

Code:
Option Compare Database
Option Explicit


Private Sub Form_Current()

End Sub

In the blank line between Private Sub etc and End Sub type

Image3.Picture = Filename

where Image3 is the name of the Image Control and Filename is the name of the field thatr contains the filename.

Now when ever you select a record on the form, the picture will appear in the Image.

Hope this makes sense, its the most typing I've done for ages [smile]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top