Solved Customise CurrentUser (1 Viewer)

Juett

Registered User.
Local time
Today, 06:47
Joined
Jul 16, 2019
Messages
71
Hi everyone,

I have a simple login form that checks the value entered in text box with prestored data in a hidden table. Once the login button is pressed, the code checks the user name matches one in the table, and if it does, the form closes and the database opens. All works well.

What I would like to achieve is when the login button is pressed, I want the entered user name in the form text box to be captured/copied and set as the Application.CurrentUser. This is so that the default text of 'admin' changes to the currently logged in user name when the Application.CurrentUser command is utilised.

Does anyone have a simple code example or method that would achieve this? I've not been able to find anything concrete on this so far.

Thanks very much
 

Minty

AWF VIP
Local time
Today, 06:47
Joined
Jul 26, 2013
Messages
10,355
I'm pretty sure that it a read-only security property?

Being able to change it on the fly would rather defeat the security model?
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 14:47
Joined
May 7, 2009
Messages
19,169
your code that check for Match on your table and if
it matches, then save the textbox Username to Tempvars variable.

Tempvars!tvarUser = me!txtUserName

now when opening a form, you show this tempvar to the form.
add code to the Load event of your form.

private sub form_load
me!label1.Caption =Tempvars!tvarUser
end sub
 

Gasman

Enthusiastic Amateur
Local time
Today, 06:47
Joined
Sep 21, 2011
Messages
14,048
Could possibly create a custom db property LoggedUser ? and set that.?
 

Juett

Registered User.
Local time
Today, 06:47
Joined
Jul 16, 2019
Messages
71
arnelgp had the solution - worked perfectly:

Login form button code:

TempVars!tvarUser = Me!txt_username.Value

parameter when stipulating the user else where: user = TempVars!tvarUser

Thanks very much
 

Users who are viewing this thread

Top Bottom