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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

login user id

Status
Not open for further replies.

jhknapp

Programmer
Jul 22, 2004
2
US
I am trying to find a way to get the user login id to see if I need to suppress a report based on whether or not the user is a supervisor. I will then check the id against a table entry and delimit the report if the person is not a supervisor.
 
You could create a parameter, and check it against your table. Limit the options if the id is not on the list.

If you need to check this against a database table (rather than hard-coding it), then it might be worth putting the check in subreport that accesses just that database table and returns a shared variable that can then be tested. (Use Search to get details if you don't know about shared variables.) Subreports are expensive in machine-time and should be avoided wherever feasible.

[yinyang] Madawc Williams (East Anglia, UK) [yinyang]
 


Here is what I use in my access database to pull the user id from our network. It works great! You might be able to modify it for Crystal.

Code:
' This code was originally written by Dev Ashish.
' It is not to be altered or distributed,
' except as part of an application.
' You are free to use it in any application,
' provided the copyright notice is left unchanged.
'
' Code Courtesy of
' Dev Ashish
'
Private Declare Function apiGetUserName Lib "advapi32.dll" Alias _
    "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long

Function fOSUserName() As String
' Returns the network login name
Dim lngLen As Long, lngX As Long
Dim strUserName As String
    strUserName = String$(254, 0)
    lngLen = 255
    lngX = apiGetUserName(strUserName, lngLen)
    If (lngX > 0) Then
        fOSUserName = Left$(strUserName, lngLen - 1)
    Else
        fOSUserName = vbNullString
    End If
End Function

Then I just call fOSUserName in various form fields or on reports in the database to display the person's network name in access. I have even created a table to track who log's into the database and the date.

You might be able to use it or it might be able to give you an idea as to which direction to go.

John
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top