get the Login user (1 Viewer)

M

Myth

Guest
Hi folks,

does anyone knows how can I find out which Login was used to open an application and connect to the SQL Server so I can put some restrictions on the form ?
Thanks in advance.
Good day.
 

Sergeant

Someone's gotta do it
Local time
Yesterday, 19:53
Joined
Jan 4, 2003
Messages
638
From where? Inside SQL Server...trigger/stored procedure? Inside Access?
 
M

Myth

Guest
From inside Access application. The idea is that I have a form constructed in access and when someone load it I need to find out wich login was used to connect to MS SQL Server so I can put restrictions on some of the controls on the form.
 

Sergeant

Someone's gotta do it
Local time
Yesterday, 19:53
Joined
Jan 4, 2003
Messages
638
This will produce the windows user name (string):
=Environ("username")

There is also an API function that can be found on this forum.
If you wish to use that, search here for "fosUserName".

I normally have a hidden form open on db open...it runs on a query against the user table, with the fosUserName function supplying criteria for the username field. In the on open event of the form, if the recordcount is zero, I force the app to close. Otherwise, I use the access level from the user table to determine what forms/buttons are available.
 
M

Myth

Guest
I found something that's pretty easy to use (transact-sql):
SELECT SUSER_SNAME()
put it in a view or procedure and it gives me the exact login used.
Thanks anyway for your effort and help.
Cheers.
 

Users who are viewing this thread

Top Bottom