Inserting Photo's to specific forms and linking to a file (1 Viewer)

Accessbeginner34

Registered User.
Local time
Today, 15:49
Joined
Mar 16, 2019
Messages
31
Also - I want to include a photo in some specific forms. I can add a picture in design layout but this then applies that picture to every record. How do I get it so it's unique to each record?

Also - is there any way you can create a link to a network folder on your pc? For example I want to be able to click a link which will take me to a folder containing all the relevant files for that record.
 

June7

AWF VIP
Local time
Today, 06:49
Joined
Mar 9, 2014
Messages
5,463
1. Save image into record in Attachment field, however, this uses up Access 2GB size limit so can just save into text field path to image file and set Image control ControlSource property to this field.

2. Certainly, save folder path in hyperlink field or use code executing FollowHyperlink to open folder.

Both topics have many discussions and examples.
 

Accessbeginner34

Registered User.
Local time
Today, 15:49
Joined
Mar 16, 2019
Messages
31
Thanks - okay I have got the hyperlink to work.

For the image - sorry I don't follow you. I am really new to Access. I have clicked on the image icon and it now shows on the layout view. However, the photo is then on every record but I want a different image on each. Could you help?
 

June7

AWF VIP
Local time
Today, 06:49
Joined
Mar 9, 2014
Messages
5,463
Don't use Picture property of Image control.

1. text field in table

2. enter the file path for image into each record

3. Image control on form or report, set ControlSource property to the field

OR

1. use a field already in table, such as EmpNumber

2. name images with the EmpNumber

3. construct file path in ControlSource with an expression, like:

="C:\Users\June\Images\" & [EmpNumber] & ".jpg"
=CurrentProject.Path & "\Images\" & [EmpNumber] & ".jpg"
="\\servername\Images\" & [EmpNumber] & ".jpg"
 
Last edited:

Accessbeginner34

Registered User.
Local time
Today, 15:49
Joined
Mar 16, 2019
Messages
31
Thanks - the table which I am using has a column with the file path to each of the photos I want to attach.

how do I get to Image control - I can see this in the form properties anywhere.
 

June7

AWF VIP
Local time
Today, 06:49
Joined
Mar 9, 2014
Messages
5,463
It is a control on the Design tab, just like a button or textbox. It is the last one. You will probably have to click down in the Controls box.
 

Accessbeginner34

Registered User.
Local time
Today, 15:49
Joined
Mar 16, 2019
Messages
31
Ah right, I've found this. I have tried linking this to the photos column in my table but it still doesn't seem to be working. I think it might be an issue with the excel table the database is linked to. The photos column in this has hyperlinks to the folders containing the photos, not the photos themselves. I am stumped. Not sure how I would work out what the file path is for a specific photo in a folder. Would I need to manually type this into each row in the excel table?
 

June7

AWF VIP
Local time
Today, 06:49
Joined
Mar 9, 2014
Messages
5,463
Cannot be hyperlink, just a simple text string of the file path.

A hyperlink is composed of 3 parts separated by # character. A calculation using string manipulation functions can extract the file path part - middle section. Let x represent your field:

=Mid(Left(x, InStrRev(x,"#")-1), InStr(x,"#")+1)

Now that expression can be in the ControlSource as long as the field is in the form or report RecordSource.
 

Accessbeginner34

Registered User.
Local time
Today, 15:49
Joined
Mar 16, 2019
Messages
31
Ok thanks - so just to make sure I am clear. My record source is set to the table which includes the column containing the hyperlink so I think this covers the last point.

In terms of the Control Source, I put the =formula below into this but substitute where you have shown an ex with the photo column? What do I use to reference the column? The letter of the column in the original source table and n excel?

Sorry - I am really new to this!!!
 

Accessbeginner34

Registered User.
Local time
Today, 15:49
Joined
Mar 16, 2019
Messages
31
Okay - I have now managed to sort out the image issue. I added the text of the file path and set the Source to this column in the excel table.

I now want to add a hyperlink into the form to link to a folder. I need this to be a different hyperlink for each record on the form. I can't seem to change the data type to hyperlink for any of the fields in my current table. I just get an error message saying object is not supported for this data type. Any ideas how I get around this?
 

June7

AWF VIP
Local time
Today, 06:49
Joined
Mar 9, 2014
Messages
5,463
Options:

1. calculate 3-part hyperlink string in textbox ControlSource: ="#" & [fieldname] & "#" and set textbox IsHyperlink property to Yes.

2. create a new hyperlink type field and populate it with the 3-part hyperlink string (an UPDATE action SQL can do that), bind textbox to field (setting IsHyperlink property to Yes might not be necessary, can't remember)

3. VBA code executing FollowHyperlink command. If FollowHyperlink gives you issues, review http://allenbrowne.com/func-GoHyperlink.html
 
Last edited:

Accessbeginner34

Registered User.
Local time
Today, 15:49
Joined
Mar 16, 2019
Messages
31
I've tried following the instructions in the go hyperlink link but still not working im afraid. I am a complete novice so probably me doing something wrong. sorry don't understand what you mean by a 3-part hyperlink string or SQL?
 

June7

AWF VIP
Local time
Today, 06:49
Joined
Mar 9, 2014
Messages
5,463
I described the structure of hyperlink in post 8. Also review http://allenbrowne.com/casu-09.html

SQL (Structured Query Language) is the language of queries. Build a query in Access with the Query Designer then switch to SQLView and you will see the SQL statement that is constructed. This is the command that Access executes when opening a query object.
 

Accessbeginner34

Registered User.
Local time
Today, 15:49
Joined
Mar 16, 2019
Messages
31
Thanks - think this is all a bit too complex for me I am afraid. I will just leave the Hyper Link out of the form. It's not that critical that we have it. Thanks for your help anyway.
 

June7

AWF VIP
Local time
Today, 06:49
Joined
Mar 9, 2014
Messages
5,463
What is too complex about option 1? It is the simplest of the 3.
 

Accessbeginner34

Registered User.
Local time
Today, 15:49
Joined
Mar 16, 2019
Messages
31
You're right - I've just got this to work It was bringing the hyperlink text through before but working now - thanks for your help.
 

Users who are viewing this thread

Top Bottom