Repost-Hyperlinking the database to photo files on a network drive

  • Thread starter Thread starter Phil F
  • Start date Start date
P

Phil F

I posted this earlier but received no response. Hopefully someone will have
some ideas about this problem.

I am creating an Access database to categorize digital photographs. I only
want the
file names in the database and not the actual images (which are located on a
network drive). I would like the file name to be hyperlinked to the image
so when clicked upon the image is displayed. The file names are in the
format IMG_xxxx.JPG where the x's are numbers representing the number/name
of the image (like IMG_8001.JPG). I have
two problems:
1. How do I convert the image numbers to actual hyperlinks for the images
already in the database without having to do so for each file "by hand"?
2. How do I set up a data entry method (like a form) so that when the file
name is entered by an employee it is hyperlinked to the location of the
actual file on the network drive? Is it possible to display the network
drive files in Access (like a combo box) so that they can be selected for
entry?

Please explain your answers simply as I am new to Access.

Thanks,
Phil F
 
Simply create a database with a field name that can store the path to the
image.

If you need to "prompt" the user to browse to a file name, and then "save"
this path + file name in above field we are going to create, the
code to pop up the file dialog is here:

http://www.mvps.org/access/api/api0001.htm

There is also a api on that web site to get *just* a folder name also.

To display the image, you can either

a) place a view button on your form, and it can launch the picture (the
viewer that will launch will be whatever is the *current* windows
default picture viewer for .jpg files,

the code behind the view button would be

application.FollowHyperlink me!NameOfFieldWithFileName

b) place a image control on the form, and use the following code to
display the image:


Me.myImage32ContorlName.Picture = me!NameOfFieldWithFileName

So, when you press the view button, the picture would display on the form.
Once you get all of this working, then you *can* consider placing some code
in the on-current event that would execute the above one line for you when
you open a form, or navigate to a new record.

I would for the most part NOT use the hyperlink field data type that tables
offer. They are just painful to use. So, use a standard text field.

You can also write some code to traverse the directories, and create a
record in a table for each picture, but, I not rally sure how that helps
you, as those records would not have any descriptions etc. Check out the
"dir" command in help if you need to do this.
 
Hi Phil

Hi

2 quick ways of doing
Create a hyperlink field in your table (I have called it [txtPhotoName])
store the links to the photos.
Your link should look something like
"C:\Documents and Settings\My Documents\My Pictures\ IMG_1234.JPG

If you cant find the right path for the photos a good “cheat†is to click
“start†then “run†then browse to the photo (select all files not just
programmes) after you have selected the photo – copy the path then cancel the
browse – paste the path into your field.

Create a query from the table and then create a from the query.

Open the form and click the hyperlink field [txtPhotoName] and your photo
will open.

Method 2
Create 3 new fields in your form.
[txtPictureNumber]
[txtPhotoPath] [hypDiverter]
Note if all your pictures are in the same location you don’t need
txtPhotoPath – but I would have it in case you one day decide to hold some
other picture elsewhere.
Set the default for [txtPhotPath] to the “path†but without the photo number.



Next create a form from this table.
Bring into the form the 3 fields (obviously there will be other fields as
well but this is just to answer you question)

Create a button on the form
On the button’s properties use this behind the OnClick event

Private Sub ButtonName_Click()
tblPhotos!hypDiverter = Forms!frmFormName!txtPictureNumber &
Forms!frmFormName!txtPhotoPath &â€.jpgâ€
End Sub

Of course you could get rid of txtPhotoPath fields all together and simply
use

Private Sub ButtonName_Click()
tblPhotos!hypDiverter = Forms!frmFormName!txtPictureNumber & "Insert path
here" &â€.jpgâ€
End Sub

But then you wouldn't be able to store the pictures anywhere else so I would
use the 1st option.

Note the table name “photos†will need to be changed to whatever you use and
that you don’t really need to have hypDiverter on the form it’s just easier
to see and problems if you do.

On the form set the visibility of [txtPhotoPath] and [hypDiverter] to No.

All you user needs to do is add the photo number into the field
[txtPictureNumber] and then click the button to store the hyperlink.

Create a goto button to open the picture at a latter stage.
 
Thank you Albert & Wayne. I will explore your suggestions tonight.

Phil F

Wayne-I-M said:
Hi Phil

Hi

2 quick ways of doing
Create a hyperlink field in your table (I have called it [txtPhotoName])
store the links to the photos.
Your link should look something like
"C:\Documents and Settings\My Documents\My Pictures\ IMG_1234.JPG

If you cant find the right path for the photos a good "cheat" is to click
"start" then "run" then browse to the photo (select all files not just
programmes) after you have selected the photo - copy the path then cancel
the
browse - paste the path into your field.

Create a query from the table and then create a from the query.

Open the form and click the hyperlink field [txtPhotoName] and your photo
will open.

Method 2
Create 3 new fields in your form.
[txtPictureNumber]
[txtPhotoPath] [hypDiverter]
Note if all your pictures are in the same location you don't need
txtPhotoPath - but I would have it in case you one day decide to hold some
other picture elsewhere.
Set the default for [txtPhotPath] to the "path" but without the photo
number.



Next create a form from this table.
Bring into the form the 3 fields (obviously there will be other fields as
well but this is just to answer you question)

Create a button on the form
On the button's properties use this behind the OnClick event

Private Sub ButtonName_Click()
tblPhotos!hypDiverter = Forms!frmFormName!txtPictureNumber &
Forms!frmFormName!txtPhotoPath &".jpg"
End Sub

Of course you could get rid of txtPhotoPath fields all together and simply
use

Private Sub ButtonName_Click()
tblPhotos!hypDiverter = Forms!frmFormName!txtPictureNumber & "Insert path
here" &".jpg"
End Sub

But then you wouldn't be able to store the pictures anywhere else so I
would
use the 1st option.

Note the table name "photos" will need to be changed to whatever you use
and
that you don't really need to have hypDiverter on the form it's just
easier
to see and problems if you do.

On the form set the visibility of [txtPhotoPath] and [hypDiverter] to No.

All you user needs to do is add the photo number into the field
[txtPictureNumber] and then click the button to store the hyperlink.

Create a goto button to open the picture at a latter stage.

--
Wayne
Manchester, England.
Enjoy whatever it is you do


Phil F said:
I posted this earlier but received no response. Hopefully someone will
have
some ideas about this problem.

I am creating an Access database to categorize digital photographs. I
only
want the
file names in the database and not the actual images (which are located
on a
network drive). I would like the file name to be hyperlinked to the
image
so when clicked upon the image is displayed. The file names are in the
format IMG_xxxx.JPG where the x's are numbers representing the
number/name
of the image (like IMG_8001.JPG). I have
two problems:
1. How do I convert the image numbers to actual hyperlinks for the
images
already in the database without having to do so for each file "by hand"?
2. How do I set up a data entry method (like a form) so that when the
file
name is entered by an employee it is hyperlinked to the location of the
actual file on the network drive? Is it possible to display the network
drive files in Access (like a combo box) so that they can be selected for
entry?

Please explain your answers simply as I am new to Access.

Thanks,
Phil F
 
Wayne,

I tried your second method.
1. Added the following TEXT fields to tbl-PhotoTest: txtPhotoNumber,
txtPhotoPath, txtHypDiverter
2. Created a form (frm-PhotoTest) based on tbl-PhotoTest adding the three
TEXT fields mentioned above from the table.
3. Set the default value for Forms![frm-PhotoTest]!txtPhotoPath to
"\\Server\Share. I have to hit ctrl + alt + spacebar to get the default
value to enter into the form because it will not enter automatically. If I
set the default value in the underlying table, the path is not entered even
when I enter the mentioned key strokes.
4. Set the form "on-click" event procedure to:

Private Sub Command15_Click()
Forms![frm-PhotoTest]!hypDiverter = Forms![frm-PhotoTest]!txtPhotoPath _
& Forms![frm-PhotoTest]!Folder & "Canon" & "\" _
& Forms![frm-PhotoTest]!txtPhotoNumber
End Sub

I had to use Forms![frm-PhotoTest]!hypDiverter instead of
tbl-PhotoTest!hypDiverter in the first line of the procedure to get it to
work at all. To run the form I do the following:
1.Copy the photo file name into the frm-PhotoTest!txtPhotoNumber field of
the form
2. Tab to the frm-PhotoTest!txtPhotoPath field and press ctrl + alt +
spacebar to get the default path to enter
3. Click the Command15 button and the frm-PhotoTest!txtHypDiverter is
populated with the correct text for the hyperlink but it is not a hyperlink.
If I had made the visitility of the frm-PhotoTest!txtHypDiverte and the
frm-PhotoTest!txtPhotoPath to NO I would not have seen the change. All
fields are populated in the underlying table after these moves but none are
hyperlinks.

Questions:
1. How do I get the txtPhotoPath field on the form to enter automatically
with out hitting ctrl + alt + spacebar ?
2. What is the hypDiverter field for? It has the text for the hyperlink but
is not a hyperlink. Why set it to "not visible" on the form?
3. How do you get the table field txtPhotoNumber to be a hyperlink so that
when you click on it the photo is shown as a thumbnail or a full view?
4. Can you use a query to update the filenames of the photos to hyperlinks?

Thank you for the help.
Phil F


Wayne-I-M said:
Hi Phil

Hi

2 quick ways of doing
Create a hyperlink field in your table (I have called it [txtPhotoName])
store the links to the photos.
Your link should look something like
"C:\Documents and Settings\My Documents\My Pictures\ IMG_1234.JPG

If you cant find the right path for the photos a good "cheat" is to click
"start" then "run" then browse to the photo (select all files not just
programmes) after you have selected the photo - copy the path then cancel
the
browse - paste the path into your field.

Create a query from the table and then create a from the query.

Open the form and click the hyperlink field [txtPhotoName] and your photo
will open.

Method 2
Create 3 new fields in your form.
[txtPictureNumber]
[txtPhotoPath] [hypDiverter]
Note if all your pictures are in the same location you don't need
txtPhotoPath - but I would have it in case you one day decide to hold some
other picture elsewhere.
Set the default for [txtPhotPath] to the "path" but without the photo
number.



Next create a form from this table.
Bring into the form the 3 fields (obviously there will be other fields as
well but this is just to answer you question)

Create a button on the form
On the button's properties use this behind the OnClick event

Private Sub ButtonName_Click()
tblPhotos!hypDiverter = Forms!frmFormName!txtPictureNumber &
Forms!frmFormName!txtPhotoPath &".jpg"
End Sub

Of course you could get rid of txtPhotoPath fields all together and simply
use

Private Sub ButtonName_Click()
tblPhotos!hypDiverter = Forms!frmFormName!txtPictureNumber & "Insert path
here" &".jpg"
End Sub

But then you wouldn't be able to store the pictures anywhere else so I
would
use the 1st option.

Note the table name "photos" will need to be changed to whatever you use
and
that you don't really need to have hypDiverter on the form it's just
easier
to see and problems if you do.

On the form set the visibility of [txtPhotoPath] and [hypDiverter] to No.

All you user needs to do is add the photo number into the field
[txtPictureNumber] and then click the button to store the hyperlink.

Create a goto button to open the picture at a latter stage.

--
Wayne
Manchester, England.
Enjoy whatever it is you do


Phil F said:
I posted this earlier but received no response. Hopefully someone will
have
some ideas about this problem.

I am creating an Access database to categorize digital photographs. I
only
want the
file names in the database and not the actual images (which are located
on a
network drive). I would like the file name to be hyperlinked to the
image
so when clicked upon the image is displayed. The file names are in the
format IMG_xxxx.JPG where the x's are numbers representing the
number/name
of the image (like IMG_8001.JPG). I have
two problems:
1. How do I convert the image numbers to actual hyperlinks for the
images
already in the database without having to do so for each file "by hand"?
2. How do I set up a data entry method (like a form) so that when the
file
name is entered by an employee it is hyperlinked to the location of the
actual file on the network drive? Is it possible to display the network
drive files in Access (like a combo box) so that they can be selected for
entry?

Please explain your answers simply as I am new to Access.

Thanks,
Phil F
 
Albert,

I was have not tried the prompting code yet that was referenced at MVPS.org.
It looks complicated.

I did try method A to display the image in the default .jpg viewer. It
worked great. I click on the View control and it obtains the complete file
path (\\Servername\share\photofilename) from the appropriate text box and
displays the photo.

I tried method B to display a "thumbnail" on the form. I plugged in the
name of the text box that contained the full path to the photo, but I
received an error like this:

Run-tie error '2114':
Microsoft Office Access doesn't support the format of the file
"\\ServerName\Photo Archive\100Cano\IMG_0079.JPG,' or file is too large..
Try converting the file to BMP or GIF format.


Any ideas how I can get method B to Work?
Could you explain the prompting scenario you described at the first of the
email?

Thanks,

Phil F
 

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

Back
Top