Results 1 to 14 of 14
  1. #1
    usfarang is offline Advanced Beginner
    Windows 10 Access 2010 64bit
    Join Date
    Mar 2021
    Posts
    42

    Display Image on form

    I'm trying to display a picture I have already for an employee on frmEmployees on another form.
    tblEmployees
    EmpID
    ProfilePicture
    Path
    'ProfilePicture field contains the full path and .jpg file location.
    I want it to display that users picture on another form.
    How can I do this? I have tried DLookup with no luck.

    Me.Pic = (DLookup("[ProfilePictureImage]", "tblEmployees", "[EmpID]='" & Me.txtUserID.Value & "'"))



  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    in a form of the record that has the photos,use a OLE bound image box for the OLE field.
    load the image into paint, select it, copy,
    in the form , paste into the image box.

    then in other forms or reports, use the image box bound to that field. It will show.

  3. #3
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,556
    Is txtUserID text of numeric?
    Any fields that I had with ID in them like EmpID, were autonumber?

    You also say ProfilePicture holds the full path to the image file, yet you use ProfilePictureImage in the DLookUp() ?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  4. #4
    usfarang is offline Advanced Beginner
    Windows 10 Access 2010 64bit
    Join Date
    Mar 2021
    Posts
    42
    ProfilePicture is the field name in the table, ProfilePath is also a field in the table. ProfilePictureImage is the actual picture with its control source set to ProfilePicture. This is all on frmEmployees and works fine.
    I need to get that picture on another form as well for the SAME person associated with it when their name is entered.
    Ex; I enter John Doe and his picture shows up. Having difficulty with the syntax is all. The actual code of course will be like this.
    "C:\Users\usfar\Pictures\Camera Roll\WIN_20211221_16_06_09_Pro.jpg"
    This comes from ProfilePicture on frmEmployees. I use a FileDialog to get the picture.
    Hope this clears everything up. Nothing is store, only linked.
    txtuserID is TEXT , it is the users name. YES EmpID is a number, PK. It is the employees ID.
    tblusers
    userID is their name, a text field.
    So if txtUserID on the form = txtuserID in tblUsers = their name.
    Last edited by usfarang; 02-28-2022 at 05:23 PM. Reason: explanation of field.

  5. #5
    usfarang is offline Advanced Beginner
    Windows 10 Access 2010 64bit
    Join Date
    Mar 2021
    Posts
    42
    Here is a screenshot of frmEmployees with the ProfilePath & ProfilePicture. ProfilePictureImage (The actual Picture = ProfilePicture as it's control source) and ProfilePath is where the picture is stored.
    Hth

    Click image for larger version. 

Name:	ProfilePictureImage.png 
Views:	22 
Size:	22.2 KB 
ID:	47351

  6. #6
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,556
    Quote Originally Posted by usfarang View Post
    ProfilePicture is the field name in the table, ProfilePath is also a field in the table. ProfilePictureImage is the actual picture with its control source set to ProfilePicture. This is all on frmEmployees and works fine.
    I need to get that picture on another form as well for the SAME person associated with it when their name is entered.
    Ex; I enter John Doe and his picture shows up. Having difficulty with the syntax is all. The actual code of course will be like this.
    "C:\Users\usfar\Pictures\Camera Roll\WIN_20211221_16_06_09_Pro.jpg"
    This comes from ProfilePicture on frmEmployees. I use a FileDialog to get the picture.
    Hope this clears everything up. Nothing is store, only linked.
    txtuserID is TEXT , it is the users name. YES EmpID is a number, PK. It is the employees ID.
    tblusers
    userID is their name, a text field.
    So if txtUserID on the form = txtuserID in tblUsers = their name.
    So you are comparing one field which is a number to another field which is text?

    You need to either find the EmpID of the user and use that in the above code, or just search for the userid in the table Employees.

    You have to match like with like. You are comparing apples and oranges.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  7. #7
    usfarang is offline Advanced Beginner
    Windows 10 Access 2010 64bit
    Join Date
    Mar 2021
    Posts
    42
    You are correct. My mistake, when trying too many different things. This is my latest attempt which still does not work. txtuserID and userID are both text fields.
    But of course this even if it worked would not get me the file name of the picture?

    Me.ProfilePicture = (DLookup("[ProfilePicture]", "tblEmployees" = "C:\Users\usfar\Pictures\Camera Roll", "tblUsers", "[userID]='" & Me.txtUserID.Value & "'"))

  8. #8
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,556
    No, with code like that, it would not.
    I would expect the path to the picture to be returned to Me.ProfilePicture.Picture

    For that to happen you would need code more like
    Code:
    Me.ProfilePicture.Picture = (DLookup("[ProfilePicture]", "tblEmployees" "[userID]='" & Me.txtUserID & "'"))
    Now if you do not have UserID in table employees, that is not going to work.
    So, get one piece of data to be able to use that for the retrieval of the picture path.

    Take it one step at a time. Why isn't UserID in tblEmployees?, there must be some way of linking users to Employees?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  9. #9
    usfarang is offline Advanced Beginner
    Windows 10 Access 2010 64bit
    Join Date
    Mar 2021
    Posts
    42
    The form does not use tblEmployees, it uses tblUsers. The picture is stored in tblEmployees.
    EmpID is in tblEmployees which is the PK. EmpName is the employees name.

    tblEmployees
    EmpID = PK
    EmpName
    ProfilePicture
    ProfilePath

    tblUsers
    userID = PK which is TEXT
    UserName = users name


    EmpName (tblEmployees)= UserName (tblUsers)
    Not that it should make a difference but the form is NOT bound.
    Last edited by usfarang; 03-01-2022 at 04:13 AM. Reason: Forgot

  10. #10
    usfarang is offline Advanced Beginner
    Windows 10 Access 2010 64bit
    Join Date
    Mar 2021
    Posts
    42
    A bit of duplication, not normalization but I want this to work. In the process of just using tblusers and adding in ProfilePicture and ProfilePath.
    Stay Tuned. Not a big issue since the files are not being stored.

  11. #11
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,556
    So from your latest update on information
    Code:
    Me.ProfilePicture.Picture = (DLookup("[ProfilePicture]", "tblEmployees" "[EmpName]='" & Me.txtUserID & "'"))
    Plus it does make a difference if the form was bound. Then you could bring in the path of the picture in the form recordsource and have no need for a Dlookup().
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  12. #12
    usfarang is offline Advanced Beginner
    Windows 10 Access 2010 64bit
    Join Date
    Mar 2021
    Posts
    42
    ="C:\Users\usfar\Pictures\Camera Roll"
    This does not work or get me the picture?
    I set the control source of the image to this, is this not correct?

  13. #13
    usfarang is offline Advanced Beginner
    Windows 10 Access 2010 64bit
    Join Date
    Mar 2021
    Posts
    42
    Now have picture on form but it does not change for the user.
    ProfilePicture="C:\Users\usfar\Pictures\Camera Roll"
    ProfilePictureImage=[ProfilePicture] & [txtUserID].[Value] & "'

  14. #14
    usfarang is offline Advanced Beginner
    Windows 10 Access 2010 64bit
    Join Date
    Mar 2021
    Posts
    42
    Blow a Horn, Sound the Trumpets, Success at last.

    Many Thanks WelshGasman for the help.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Image display in form
    By WAVP375 in forum Access
    Replies: 3
    Last Post: 09-19-2020, 02:31 PM
  2. Replies: 5
    Last Post: 07-10-2020, 12:41 PM
  3. Form will not display image attachment from subform
    By standonthefloor in forum Forms
    Replies: 2
    Last Post: 03-05-2019, 09:58 AM
  4. Replies: 10
    Last Post: 02-25-2019, 07:36 PM
  5. Replies: 3
    Last Post: 10-16-2015, 03:04 PM

Tags for this Thread

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