Directing user to specific form based on windows ID

Johnny Drama

In need of beer...
Local time
Today, 15:14
Joined
Dec 12, 2008
Messages
211
Hi all,

I'm assuming it's possible, but haven't a clue as to how to go about it, to have a user directed to a specific form based upon their windows user ID when they launch the DB. Anyone know how to accomplish this?

Thanks in advance.
 
This link shows how to retrieve the Windows User name. Once you have that you can then test it and determine which form you wish to show them.
 
Hi John,
My attempt with Access 2010 & windows xp returns "user1"

Any suggestions on what may be causing this ?

Regards,
Bill
 
Not sure Bill. I've just tested the module from the link and it works fine in Vista and '07.

The only thing I can think of is that your system recognises you as user1
 
Yes, you must be correct but I can not find out how to change same :confused:

We have a login form for the database which means the pc is not user specific only the database is.
 
I'm assuming that Johnny Drama is working in an environment where a number of users have individual log in ID's to the one computer and is wanting to configure the DB at PC user log in level rather than at DB log in level. If that makes sense :o
 
You are correct, JBB. My question now is once I retrieve the user's login ID, do I use a Case statement to determine which form they are routed to or an If/Then/Else.
 
You are correct, JBB. My question now is once I retrieve the user's login ID, do I use a Case statement to determine which form they are routed to or an If/Then/Else.

Are you going to store different login names in a table? If so, you could dlookup the username from the table and collect the allowed form from there then, open the form

Nidge
 
No plans to store logins. Just need to pass the ID and use it to open one or the other form.
 
You are correct, JBB. My question now is once I retrieve the user's login ID, do I use a Case statement to determine which form they are routed to or an If/Then/Else.
In this situation, I'd open up a Generic Welcome Screen and use a Case Statement, in that form's On Load event to determine the next form the user sees.
 
No plans to store logins. Just need to pass the ID and use it to open one or the other form.

Hi,

how are you expecting to control the form allocation if the usernames / id's are not being stored? If you hard code them, then you'll have to update the FE everytime a user needs to be added / removed. If it was me, i would have a table storing the ID. When the user started the app, the Id would be captured, checked against the table and the form name retrived. This form would then be the one that opened. example ( called from AutoExec )

Code:
Function ShowUserForm()
Dim sEnviron As String
Dim sFormName As String
 
sEnviron = Environ("UserName")
sformName = DLookup("frmUserForm", "tblUsers", "UserID='" & sEnviron & "'")
 
doCmd.OpenForm  sFormName
End Function

Cheers

Nidge
 
Updating the FE will be extremely rare, but I get what your saying. Thanks for all the help gents.
 

Users who are viewing this thread

Back
Top Bottom