Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Code For ADP to show the current user 1

Status
Not open for further replies.

Aliffi

MIS
Jan 9, 2005
51
BE
Hi guys,

iam pending with a short method
i forgot how to call or show the current user name loged to an ADP ....

i want ADP form to display the Current User of the SQL SERVER who is loged to database.

regards
aliffi
 
In SQL Server, use "system_user"

Example:
Use SYSTEM_USER to return the current system username

This example declares a char variable, puts the current value of SYSTEM_USER into the variable, and then prints the variable.

DECLARE @sys_usr char(30)
SET @sys_usr = SYSTEM_USER
SELECT 'The current system user is: '+ @sys_usr
GO
 
You can put a public function in the standard module to call whenever you need the user name.

Public Function ReturnUserRemote() As String
Dim cn As New ADODB.Connection, sql1 As String
Dim rs As New ADODB.Recordset, connString As String

connString = "provider=SQLOLEDB.1;" & _
"User ID=yourid;" & _
"Initial Catalog=ReportInventory;" & _
"Data Source=Boxer;" & _
"Password=yourpassw;" & _
"Persist Security Info=True"

cn.ConnectionString = connString
cn.Open connString

sql1 = "Select suser_sname() "
Set rs.ActiveConnection = CurrentProject.Connection
rs.Open sql1, cn, adOpenStatic, adLockOptimistic

ReturnUserRemote = rs(0)
Debug.Print "user name = "; rs(0)

rs.Close
Set rs = Nothing
End Function

 
no dear ! i think you did not get me fully

what i mean is .....how can i display the current SQL SERVER user logged to SQL ADP .....on a ADP form ....when i open the form it automatically show the user name like
jhon, sa or .....

regards \

help
 
So, what did you get when you tried the above example suggested?
 
Try this

Me.Label5.Caption = CurrentProject.Connection.Properties("User Id")

you could also us a text box depending on what you're trying to do

hope it's helpful
 
Dear AQ07 Thanks a world it really worked .

Wish you best of success in your life

hope you be in touch wiht us
thanks alot once again

Aliffi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top