I have a database on which I have a module that picks up the NT use ID:
GetNetworkUser
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 = ""
End If
'if null then tell the user that no valid log-in was captured
If fOSUserName = "" Then
strerror = "No Valid user id was detected!" & vbCrLf & vbCrLf
strerror = strerror & "Are you logged into Novell?" & vbCrLf
MsgBox strerror, vbCritical, strDbName
DoCmd.close "frm_Splash"
End If
End Function
I then have a form that opens upon load that has a field that captures that userID.
Based on the ID result, I want the database to then open the appropriate switchboard. I have a table of users and their associated rights and wrote the following but it isn't working.
Private Sub Form_Load()
Me.Caption = "Please Wait...Starting Application"
Me!continue_label.Visible = False
DoCmd.RunSQL "DELETE GL8_BudgetAndHistory.* FROM GL8_BudgetAndHistory;"
DoCmd.RunSQL "INSERT INTO GL8_BudgetAndHistory SELECT GL8_BudgetAndHistory1.* FROM GL8_BudgetAndHistory1;"
If DCount("[fldID]", "westek users", "[fldID]=[forms]![frm_splash]![cUser]" = 0 Then
MsgBox "You are not a valid user of this application.", vbCritical, "Invalid User"
Quit
Else
Dim uPass As String
uPass = DLookup("[fldDepartment]", "westek users", "[fldID]=[forms]![frm_splash]![cUser]"
If uPass = "Admin" Then
DoCmd.OpenForm "Switchboard"
ElseIf uPass = "Sales Mgmt" Then
DoCmd.OpenForm "Sales Switchboard"
DoCmd.OpenForm "Marketing Switchboard"
ElseIf uPass = "Materials" Then
DoCmd.OpenForm "Materials Switchboard"
ElseIf uPass = "Fiber" Then
DoCmd.OpenForm "Fiber Switchboard"
ElseIf uPass = "HR" Then
DoCmd.OpenForm "HR Switchboard"
ElseIf uPass = "Facilities" Then
DoCmd.OpenForm "Facilities Switchboard"
ElseIf uPass = "Planning" Then
DoCmd.OpenForm "Planning Switchboard"
ElseIf uPass = "MIS" Then
DoCmd.OpenForm "MIS Switchboard"
ElseIf uPass = "Corporate" Then
DoCmd.OpenForm "Switchboard"
ElseIf uPass = "QC" Then
DoCmd.OpenForm "QC Switchboard"
ElseIf uPass = "Engineering" Then
DoCmd.OpenForm "Engineering Switchboard"
ElseIf uPass = "Accounting" Then
DoCmd.OpenForm "Accounting Switchboard"
ElseIf uPass = "Production" Then
DoCmd.OpenForm "Production Switchboard"
ElseIf uPass = "Operations" Then
DoCmd.OpenForm "Materials Switchboard"
DoCmd.OpenForm "Fiber Switchboard"
DoCmd.OpenForm "Facilities Switchboard"
DoCmd.OpenForm "Planning Switchboard"
DoCmd.OpenForm "QC Switchboard"
DoCmd.OpenForm "Production Switchboard"
DoCmd.OpenForm "Engineering Switchboard"
DoCmd.close "frm_Splash"
End If
End If
End Sub
I am not a programmer and am piecing code together and don't know how to tie the code behind the form to the module. bottom line, I don't want the users to have to logon on and that is why I am not using the Access security. Any ideas?
GetNetworkUser
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 = ""
End If
'if null then tell the user that no valid log-in was captured
If fOSUserName = "" Then
strerror = "No Valid user id was detected!" & vbCrLf & vbCrLf
strerror = strerror & "Are you logged into Novell?" & vbCrLf
MsgBox strerror, vbCritical, strDbName
DoCmd.close "frm_Splash"
End If
End Function
I then have a form that opens upon load that has a field that captures that userID.
Based on the ID result, I want the database to then open the appropriate switchboard. I have a table of users and their associated rights and wrote the following but it isn't working.
Private Sub Form_Load()
Me.Caption = "Please Wait...Starting Application"
Me!continue_label.Visible = False
DoCmd.RunSQL "DELETE GL8_BudgetAndHistory.* FROM GL8_BudgetAndHistory;"
DoCmd.RunSQL "INSERT INTO GL8_BudgetAndHistory SELECT GL8_BudgetAndHistory1.* FROM GL8_BudgetAndHistory1;"
If DCount("[fldID]", "westek users", "[fldID]=[forms]![frm_splash]![cUser]" = 0 Then
MsgBox "You are not a valid user of this application.", vbCritical, "Invalid User"
Quit
Else
Dim uPass As String
uPass = DLookup("[fldDepartment]", "westek users", "[fldID]=[forms]![frm_splash]![cUser]"
If uPass = "Admin" Then
DoCmd.OpenForm "Switchboard"
ElseIf uPass = "Sales Mgmt" Then
DoCmd.OpenForm "Sales Switchboard"
DoCmd.OpenForm "Marketing Switchboard"
ElseIf uPass = "Materials" Then
DoCmd.OpenForm "Materials Switchboard"
ElseIf uPass = "Fiber" Then
DoCmd.OpenForm "Fiber Switchboard"
ElseIf uPass = "HR" Then
DoCmd.OpenForm "HR Switchboard"
ElseIf uPass = "Facilities" Then
DoCmd.OpenForm "Facilities Switchboard"
ElseIf uPass = "Planning" Then
DoCmd.OpenForm "Planning Switchboard"
ElseIf uPass = "MIS" Then
DoCmd.OpenForm "MIS Switchboard"
ElseIf uPass = "Corporate" Then
DoCmd.OpenForm "Switchboard"
ElseIf uPass = "QC" Then
DoCmd.OpenForm "QC Switchboard"
ElseIf uPass = "Engineering" Then
DoCmd.OpenForm "Engineering Switchboard"
ElseIf uPass = "Accounting" Then
DoCmd.OpenForm "Accounting Switchboard"
ElseIf uPass = "Production" Then
DoCmd.OpenForm "Production Switchboard"
ElseIf uPass = "Operations" Then
DoCmd.OpenForm "Materials Switchboard"
DoCmd.OpenForm "Fiber Switchboard"
DoCmd.OpenForm "Facilities Switchboard"
DoCmd.OpenForm "Planning Switchboard"
DoCmd.OpenForm "QC Switchboard"
DoCmd.OpenForm "Production Switchboard"
DoCmd.OpenForm "Engineering Switchboard"
DoCmd.close "frm_Splash"
End If
End If
End Sub
I am not a programmer and am piecing code together and don't know how to tie the code behind the form to the module. bottom line, I don't want the users to have to logon on and that is why I am not using the Access security. Any ideas?