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!

Budget Database

Status
Not open for further replies.

JCridland

Technical User
Jul 2, 2001
32
0
0
US
I have a database that I have created that I am having trouble getting the on open form to follow the code to open other forms based on the userID. The following is the event procedure on the start up form:

Private Sub Form_Open(Cancel As Integer)
'Dim rctOriginal As adhTypeRect
'Call adhScaleForm(Me, 640, 461, 96, 96, rctOriginal)
Application.SetOption "Confirm Record Changes", False
Application.SetOption "Confirm Document Deletions", False
Application.SetOption "Confirm Action Queries", False
Exit Sub


Me![cUser] = CurrentUser()
If DCount("[fldID]", "westek users", "[fldID]=[forms]![westek]![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]![westek]![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"
End If
DoCmd.Close
End If
End Sub

I also am using cuser as a query to the table "westek users" in which permissions have been granted. I am stumped.
 
Does fldID have values that exactly match the user's logon id? Typically, an ID field is numeric whereas a logon id is text. Are you getting an error message or is the problem a logical one?
 
The 7th line "Exit Sub" precludes all following.

MichaelRed
mred@att.net

There is never time to do it right but there is always time to do it over
 
When I delete the "exit sub" from the code, I get an error 2448 stating I can't assign a value to the object and debug highlights the Me![cuser] line.

Jerry - in answer to your question, yes, fldID contains values that exactly matc the user's NT logon.
 
Well, that is at least "progress". You know where the next problem is. the syntax of the line suggests that "[cUser] could coule be either a field in the recordsource or a control on the form (one which supports a text datatype) - or possibly both? Do you know which ? Try commenting this line 'out'. It only (should) be displaying the user name in a control.

MichaelRed
mred@att.net

There is never time to do it right but there is always time to do it over
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top