How to get logged in ID on Navigation form (1 Viewer)

mba_110

Registered User.
Local time
Today, 09:19
Joined
Jan 20, 2015
Messages
280
Hi

I am trying to get user's name based on their login ID recorded in tblUserSecurity on to Navigation form after they logged in database.

example.

if Ee55er is login id and his name John Edgar the result should appear as John Edgar based on login ID verification on Navigation form.

Here is my try on Navigation Form Load event.

Code:
Me.txtUsernameEmpNav = "frmLogin","[LoginID]" then
DLookUp("[EmpID].column(1)","[tblUserSecurity]","[LoginID]='" & "[frmLogin]![txtUsername]" & "'")

thanks for your help.
 

Minty

AWF VIP
Local time
Today, 16:19
Joined
Jul 26, 2013
Messages
10,354
So the $50,000 question is

What doesn't happen ? What's the error code?
The code as posted won't compile.
 

mba_110

Registered User.
Local time
Today, 09:19
Joined
Jan 20, 2015
Messages
280
Ooooh MY GOD I FORGOT TO PUT THE ERROR MESSAGE :( , I AM SO BAD :eek: .

Obviously the common sense is the code is not correct and not executing the described task hence, i am here and their is no error messages again common sense hence, it was not posted in above. :banghead:
 

isladogs

MVP / VIP
Local time
Today, 16:19
Joined
Jan 14, 2017
Messages
18,186
Your code makes little sense and has many errors.
For example, you can't use Column(1) in a DLookup IIRC.
Try this

Code:
Me.txtUsernameEmpNav = 
Nz(DLookUp("EmpID","tblUserSecurity","LoginID='" & Forms!frmLogin.txtUsername & "'"),"")

I've made a few assumptions so it may need tweaking
 

Dreamweaver

Well-known member
Local time
Today, 16:19
Joined
Nov 28, 2005
Messages
2,466
I just use a hidden form for current user like


Me![Label5].Caption = [Forms]![your_form]![User_Name]



You could add at end

& " Loged in"
 

Minty

AWF VIP
Local time
Today, 16:19
Joined
Jul 26, 2013
Messages
10,354
Well I'm sorry my normal omnipotence wasn't working at 100% earlier, I'll get some new batteries fitted at lunch time.

If you have a login form, why not also set a global property for the user name and EmpID on that login screen that you can use anywhere.
Something like this might work if our crystal balls are up to speed;

Code:
Option Compare Database
Option Explicit
Private pUser As String

Public Property Get glUserName() As String
   [COLOR="SeaGreen"] 'Uses a self-healing property to return the network username
    'Thanks to Brent Spaulding (datAdrenaline), MVP for the function
    'to retrieve the username without using API
    'Thanks to Jack Leach (jleach), MVP for the idea on self-healing properties
    'Source: http://accessmvp.com/thedbguy
    'Usage: Me.ControlName = modUser.glUsername[/COLOR]

    If pUser > "" Then
        'Just return the existing username
    Else
        'Get username
        pUser = [frmLogin]![txtUsername]
    End If
        
        
    glUserName = pUser

End Property

Public Property Get glEmpID() As String
   [COLOR="seagreen"] 'Uses a self-healing property to return the Employee ID
    'Thanks to Brent Spaulding (datAdrenaline), MVP for the function
    'to retrieve the username without using API
    'Thanks to Jack Leach (jleach), MVP for the idea on self-healing propeties
    'Source: http://accessmvp.com/thedbguy
    'Usage: Me.ControlName = modUser.glEmpID[/COLOR]

    If pUser > "" Then
        'Just return the existing username
    Else
        'Get username
        pUser = [frmLogin]![txtUsername]
    End If
        
        
    glEmpID = Nz(DLookUp("EmpID","tblUserSecurity","LoginID='" & pUser  & "'"),"")


End Property
 

Users who are viewing this thread

Top Bottom