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

database using network user IDs

Status
Not open for further replies.

JCridland

Technical User
Jul 2, 2001
32
0
0
US
I have a database in which I am using the following module to get the network user ID. I want to avoid having the user having to login again to Access. The database opens with a form that has a field that picks up the network user ID using this module:

Option Compare Database

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, strerror As String

strUserName = String$(254, 0)
lngLen = 255
lngX = apiGetUserName(strUserName, lngLen)

If lngX <> 0 Then
fOSUserName = left$(strUserName, lngLen - 1)
Else
fOSUserName = &quot;&quot;
End If

'if null then tell the user that no valid log-in was captured
If fOSUserName = &quot;&quot; Then
strerror = &quot;No Valid user id was detected!&quot; & vbCrLf & vbCrLf
strerror = strerror & &quot;Are you logged into Novell?&quot; & vbCrLf

MsgBox strerror, vbCritical, strDbName
End If

End Function

Based on the name in that field, I want to tie that field and compare the name to the entries I have in a table I have created that stipulates the permissions. I have written the following (or a variation of the following) to direct the user to the appropriate switchboard. Since I am not a programmer, I cannot figure out how to tie the two. Have I overcomplicated things?

Can I use the access security in conjunction with the network user ID module and the table instead?
Else

Dim uPass As String
uPass = DLookup(&quot;[fldDepartment]&quot;, &quot;westek users&quot;, &quot;[fldID]=[forms]![frm_splash]![cUser]&quot;)
If uPass = &quot;Admin&quot; Then
DoCmd.OpenForm &quot;Switchboard&quot;
ElseIf uPass = &quot;Sales Mgmt&quot; Then
DoCmd.OpenForm &quot;Sales Switchboard&quot;
DoCmd.OpenForm &quot;Marketing Switchboard&quot;
ElseIf uPass = &quot;Materials&quot; Then
DoCmd.OpenForm &quot;Materials Switchboard&quot;
ElseIf uPass = &quot;Fiber&quot; Then
DoCmd.OpenForm &quot;Fiber Switchboard&quot;
ElseIf uPass = &quot;HR&quot; Then
DoCmd.OpenForm &quot;HR Switchboard&quot;
ElseIf uPass = &quot;Facilities&quot; Then
DoCmd.OpenForm &quot;Facilities Switchboard&quot;
ElseIf uPass = &quot;Planning&quot; Then
DoCmd.OpenForm &quot;Planning Switchboard&quot;
ElseIf uPass = &quot;MIS&quot; Then
DoCmd.OpenForm &quot;MIS Switchboard&quot;
ElseIf uPass = &quot;Corporate&quot; Then
DoCmd.OpenForm &quot;Switchboard&quot;
ElseIf uPass = &quot;QC&quot; Then
DoCmd.OpenForm &quot;QC Switchboard&quot;
ElseIf uPass = &quot;Engineering&quot; Then
DoCmd.OpenForm &quot;Engineering Switchboard&quot;
ElseIf uPass = &quot;Accounting&quot; Then
DoCmd.OpenForm &quot;Accounting Switchboard&quot;
ElseIf uPass = &quot;Production&quot; Then
DoCmd.OpenForm &quot;Production Switchboard&quot;
ElseIf uPass = &quot;Operations&quot; Then
DoCmd.OpenForm &quot;Materials Switchboard&quot;
DoCmd.OpenForm &quot;Fiber Switchboard&quot;
DoCmd.OpenForm &quot;Facilities Switchboard&quot;
DoCmd.OpenForm &quot;Planning Switchboard&quot;
DoCmd.OpenForm &quot;QC Switchboard&quot;
DoCmd.OpenForm &quot;Production Switchboard&quot;
DoCmd.OpenForm &quot;Engineering Switchboard&quot;

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top