Page 1 of 2 12 LastLast
Results 1 to 15 of 22
  1. #1
    LeonS is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jul 2014
    Posts
    115

    Path to Linked Image

    I have followed guidance and now have a photo showing when a Contacts details are shown on the Contacts Form. The system is straightforward.
    However, I think for an non-database savvy user, the path is not easy. Also 90% of the path (to the images file) is the same every time. I would like to be able to shorten the input field, so the user only has to enter the JPG or PNG image name eg JohnSmith.jpg - MaryBrown.png.
    Elsewhere in the DB Guide are instructions how the install the Image directory. There are 2 parts to this - "People" and "Icons". The Icons feed the images on the various forms, and will stay the same- unless there is an update. The People will depend on how many photos the user has of the actual contacts.


    I attach a scan of the current view. I hope this helps. LeonClick image for larger version. 

Name:	AccessForumPathPhoto.jpg 
Views:	44 
Size:	50.4 KB 
ID:	46158

  2. #2
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,979
    I save the folder path in a settings table and recall it using a public variable (or TempVar) and save the file name as a separate field
    Then concatenate them to obtain the full image path
    For example:

    Code:
    strImageFolder = "G:\MyAppName\Images\" 'saved in a Settings table
    
    strFileName = "MaryBrown.png"
    
    Me.txtImagePath = strImageFolder & strFileName
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  3. #3
    LeonS is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jul 2014
    Posts
    115
    Isladogs - many thanks for that. And I see what and how you achieve the end result. Very good. I have just done some concatenate work in a "FullName" field in my Master1 table - and it works. Thus I understand the principle. But the complete coding is currently beyond me. Thank you again, and I will work on it!! Leon

  4. #4
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,803
    You could research how to use the msoFileDialogFilePicker (or folder picker, but for this I think file picker). One of its properties is the starting path (InitialFileName) which you could set to be this 'same' folder. If this folder varies for each user, you could store that path as one of their user attributes, then retrieve that value based on the user.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    LeonS is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jul 2014
    Posts
    115
    Both - Thanks for your thoughts. Given my expertise in coding, I have been working on using the Master1 table and the (new) Settings table as the source of the information to feed the controls. In the Settings table, I have entered the base Path in one field and the Image name in another. I have created a field that concatenates these two fields to produce the complete path. I want to have the Image name (eg JoanSmith.png) being able to be input by the user on the Contacts page - just below where the photo is to appear. Then I want to have Image Box use the concatenated field in the Settings table to provide the full path to the image.
    So, 1. is it possible and 2. is it a good way the solve the problem? I have not really be able to test my work as the difficulty I have, is one of getting a field on my Contacts form getting its data from a table that is not "on" the form. I have tried using a subForm but that looks dreadful. Leon
    PS I apologise for not using a standard route but I am trying to you MY expertise - such as it is!!

  6. #6
    LeonS is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jul 2014
    Posts
    115
    The is the image of the new settings table. Click image for larger version. 

Name:	SettingsTable.jpg 
Views:	36 
Size:	101.2 KB 
ID:	46163

  7. #7
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,979
    No that's not what I meant.
    The ImagePath is a field in a separate Settings table. The field value is stored once.
    The ImageName is a field in your Contacts table along with last name, First name etc
    The PhotoName field is not stored in a table as it is duplicating data.
    The concatenation is done as a query field as needed or just in your form's image control.

    Also I recommend you avoid the use of subdatasheets. Using these can be confusing to end users and reduces performance as the Subdatasheet has to be loaded each time as well as the main table
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  8. #8
    LeonS is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jul 2014
    Posts
    115
    Isladogs - got that, thanks. I have done what you suggested to the Settings and Masster1 tables. I have created a query which concatenates the 2 field into one. I have created an Image Control on the form. How do I get it to look at the Query for the image? I need to be careful as there will not always be a photo for every contact/ record. The data control for the Image Control only lists items from Master1. I cannot find a way to get the result of the PhotoNameQ.

  9. #9
    LeonS is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jul 2014
    Posts
    115
    Isladogs - Please find below an image of the workings of the PhotoNameQ It is supposed to concatenate the fields. It does not work. The taable names and the field names are correct. But when I run the query, I get no answers!! Any printable thoughts??

    Click image for larger version. 

Name:	PhotoNameQ-Concatenate.png 
Views:	33 
Size:	28.3 KB 
ID:	46165

  10. #10
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    As Colin is off-line - Remove the link between the settings table and your master data, assuming you only have one record in your settings table.
    Don't show the Image path as a column in the query results.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  11. #11
    LeonS is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jul 2014
    Posts
    115
    Minty - Excellent! It works and I get a result from the Query. Thanks!
    Now how do I get the Image Control on the Contact Form to link to the Query result? Do I enter something like "[[Query].PhotoNameQ.photoName] into Control Source of the Image Box? And, of course, I have tried that and it does not work. But am I on the right track - or is there another way I can get the Image Control to get the image data?

  12. #12
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    Assuming your form is bound to the query, set the image control to the query field (PhotoName ?)

    If it isn't, use a dlookup in the current event of the form to set the path from the query based on the ID field.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  13. #13
    LeonS is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jul 2014
    Posts
    115
    Minty - Thanks - but the form is bound to the Master1 table. I have input the following into the Control Source of the Image Box:
    DLookup("[PhotoName]", "PhotoNameQ", "[IDSettings] = 1")
    Where PhotoName is the concatenated field giving the full path, PhotoNameQ is the name of the Query and IDSettings is a result in that Query. When I run the Query, I get all four of the current records (there are only 4 records in Master1). I hope this helps explain the predicament. How do I adjust either the Query or the DLookUP in the Control Source? Leon

  14. #14
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    You should be looking for the master ID record, not the settings ID, that will be the same for all records.
    In fact it's point less retrieving that in the query results. Something more like

    DLookup("[PhotoName]", "PhotoNameQ", "[IDMaster1] = " & IDMaster1)
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  15. #15
    LeonS is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jul 2014
    Posts
    115
    Minty - thanks for that. I still cannot get it to work!
    In the Master1 table there is a field called “ImageName”. In the Settings table there are 2 fields, the IDSettings and “ImagePath”. In the Query called “PhotoNameQ”, there are 2 tables ‘Settings’ and ‘Master1’. They are not linked, although there is a field called “IDSettings” in both.
    In the Query “PhotoNameQ” there is a concatenated field containing the following:
    “PhotoName: [ImagePath] & [ImageName]”
    In the Contacts form, where the image is to appear, there is a TextBox called “ImageName” which feeds the Master1 table. The ImageName is, typically, “JohnSmith.JPG”.
    In the Contacts form there is an ImageBox called “Image262”. The Data Control Source of that ImageBox contains the following:
    “DLookup("[PhotoName]", "PhotoNameQ", "[IDMaster1] = " & IDMaster1)” – which you should recognise as the information you sent me.
    But it does not work. I am still learning, so any help would be appreciated. What am I doing wrong? Leon

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 10
    Last Post: 02-25-2019, 07:36 PM
  2. Replies: 2
    Last Post: 08-22-2018, 12:15 PM
  3. Replies: 6
    Last Post: 03-22-2018, 12:02 PM
  4. Replies: 7
    Last Post: 02-07-2017, 05:19 PM
  5. Replies: 1
    Last Post: 12-26-2016, 08:57 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums