Who is Logged In Picture on Form

User avatar
burrina
4StarLounger
Posts: 550
Joined: 30 Jul 2014, 23:58

Who is Logged In Picture on Form

Post by burrina »

New Feature trying to add.
Users Picture (path) is stored in tblEmployees.
tblEmployees
EmployeeID
ProfilePicture (Text)
ProfilePath (text)

frmEmployees
Image named ProfilePictureImage that shows their picture.
All is well.

I need to display their picture on the Main form named frmMain
I have a field txtuserid which captures the user name from frmLogin
I also have a image on frmMain named ProfilePictureImage that I want to display their picture.
Any Help Appreciated

User avatar
HansV
Administrator
Posts: 73871
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Who is Logged In Picture on Form

Post by HansV »

In the On Load event of frmMain:

Code: Select all

Private Sub Form_Load()
    Me.ProfilePictureImage.Picture = DLookup("ProfilePath", "tblEmployees", "EmployeeID='" & Me.txtuserid & "'") & "\" & _
        DLookup("ProfilePicture", "tblEmployees", "EmployeeID='" & Me.txtuserid & "'")
End Sub
If the ProfilePath field ends in \, you should omit & "\" from the above code.
Regards,
Hans

User avatar
burrina
4StarLounger
Posts: 550
Joined: 30 Jul 2014, 23:58

Re: Who is Logged In Picture on Form

Post by burrina »

Data type mismatch since EmployeeID is numeric and txtuserid is text
Now I need to capture the EmployeeID somehow I guess for the user logging in???

User avatar
HansV
Administrator
Posts: 73871
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Who is Logged In Picture on Form

Post by HansV »

Indeed, store EmployeeID in txtuserid , and change the code to

Code: Select all

Private Sub Form_Load()
    Me.ProfilePictureImage.Picture = DLookup("ProfilePath", "tblEmployees", "EmployeeID=" & Me.txtuserid) & "\" & _
        DLookup("ProfilePicture", "tblEmployees", "EmployeeID=" & Me.txtuserid)
End Sub
Regards,
Hans

User avatar
burrina
4StarLounger
Posts: 550
Joined: 30 Jul 2014, 23:58

Re: Who is Logged In Picture on Form

Post by burrina »

You do not have the required permissions to view the files attached to this post.

User avatar
HansV
Administrator
Posts: 73871
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Who is Logged In Picture on Form

Post by HansV »

I edited my previous reply immediately after posting it. It's better to view the post in the forum than in the email notification, in case the poster edits it, as here.
Regards,
Hans

User avatar
burrina
4StarLounger
Posts: 550
Joined: 30 Jul 2014, 23:58

Re: Who is Logged In Picture on Form

Post by burrina »

Thanks. I could not get it to work.
Will keep on trying. I have scaled down to demo it.
You do not have the required permissions to view the files attached to this post.