Go Back   Access World Forums > Microsoft Access Discussion > Forms

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 12-13-2018, 03:24 AM   #1
mba_110
Newly Registered User
 
Join Date: Jan 2015
Posts: 204
Thanks: 0
Thanked 0 Times in 0 Posts
mba_110 is on a distinguished road
How to get logged in ID on Navigation form

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.

mba_110 is offline   Reply With Quote
Old 12-13-2018, 03:28 AM   #2
Minty
AWF VIP
 
Minty's Avatar
 
Join Date: Jul 2013
Location: UK - Wiltshire
Posts: 5,864
Thanks: 141
Thanked 1,580 Times in 1,552 Posts
Minty has a spectacular aura about Minty has a spectacular aura about Minty has a spectacular aura about
Re: How to get logged in ID on Navigation form

So the $50,000 question is

What doesn't happen ? What's the error code?
The code as posted won't compile.
__________________
If we have helped please add to our reputation - click the scales symbol on the left, tick 'I approve' and leave a comment.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Minty is offline   Reply With Quote
Old 12-13-2018, 03:34 AM   #3
mba_110
Newly Registered User
 
Join Date: Jan 2015
Posts: 204
Thanks: 0
Thanked 0 Times in 0 Posts
mba_110 is on a distinguished road
Re: How to get logged in ID on Navigation form

Ooooh MY GOD I FORGOT TO PUT THE ERROR MESSAGE , I AM SO BAD .

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.

mba_110 is offline   Reply With Quote
Old 12-13-2018, 03:45 AM   #4
isladogs
Part time moderator
 
isladogs's Avatar
 
Join Date: Jan 2017
Location: Somerset, UK
Posts: 7,791
Thanks: 96
Thanked 1,942 Times in 1,806 Posts
isladogs is a glorious beacon of light isladogs is a glorious beacon of light isladogs is a glorious beacon of light isladogs is a glorious beacon of light isladogs is a glorious beacon of light
Re: How to get logged in ID on Navigation form

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
__________________
If this answer has helped, please click the Thanks button and/or click the 'reputation scales' symbol on the left.

Website links:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


Colin
Previously known as ridders : Access 2010 32-bit, Access 2016 32-bit & 64-bit, SQL Server Express 2014, Windows 10,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
isladogs is offline   Reply With Quote
Old 12-13-2018, 04:05 AM   #5
MickJav
Newly Registered User
 
Join Date: Nov 2005
Location: Margate
Posts: 692
Thanks: 35
Thanked 15 Times in 14 Posts
MickJav is on a distinguished road
Re: How to get logged in ID on Navigation form

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"
__________________
If an example or something I have done has helped you please click the scales or thanks.


Examples
Calendar/Holidays Example:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Spin Up/Spin Down Example:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Find And Replace Tool:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Stop Watch Timer:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
MickJav is offline   Reply With Quote
Old 12-13-2018, 05:12 AM   #6
Minty
AWF VIP
 
Minty's Avatar
 
Join Date: Jul 2013
Location: UK - Wiltshire
Posts: 5,864
Thanks: 141
Thanked 1,580 Times in 1,552 Posts
Minty has a spectacular aura about Minty has a spectacular aura about Minty has a spectacular aura about
Re: How to get logged in ID on Navigation form

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
    '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

    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
    '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

    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

__________________
If we have helped please add to our reputation - click the scales symbol on the left, tick 'I approve' and leave a comment.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Minty is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Referencing a combobox on a Navigation Form within another Navigation Form hueyhewy Queries 2 07-10-2016 11:50 AM
Embed A Navigation Form Instead Of Using Tabs (navigation Form As Subform) jerem Forms 3 10-22-2014 06:00 PM
Display logged user name on the form foxtet Forms 1 07-21-2011 12:55 AM
Filter a form by whom is logged on? unluckytoe General 3 03-11-2010 10:23 AM




All times are GMT -8. The time now is 11:02 AM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World