R
Ron
I have this Dlookup routine attached to the OnLoad
function of a Form.
It looks up the User Level of the current user
logged in at the time, who should exist in one of 2 tables.
Depending on their assigned UserLevel# determines what
controls they see on the Startup form.
The code works perfectly if the user belongs to one of the
tables, but it gives a "Type Mismatch" error if it can't
find a logged in user. The "ElseIf" statement with
a "MsgBox" function I thought would have helped to take
care of that, but it doesn't.
Can anyone see, judging by the code, why a "Type Mismatch"
would occur. I can't seem to figure it out.
Any help would be appreciated.
Thanks.
Ron (See routine below)
---------------------------------------------------------
Private Sub Form_Load()
Dim strUserLevel As String, strUser As String
strUser = CurrentUser()
strUserLevel = Nz(DLookup
("pUserLevel", "[tblProjectMgrs]", _
"ProjectName=""" & strUser & """"), "")
With Me
If strUserLevel = "" Then
strUserLevel = Nz(DLookup"
tUserLevel", "[refTMSStrategyMgr]", _
"StrategyMgr=""" & strUser & """"), "")
If strUserLevel = 2 Then
.cmdOpenDMJIform.Visible = False
.DMJobTrackinglabel.Visible = False
ElseIf strUserLevel = "" Then
MsgBox "User" & CurrentUser() & "is
not in either table." & _
"Please contact the system Admin to
add you to the appropriate table.", vbOKOnly
.cmdOpenIBTform.Visible = False
.cmdOpenScriptTrackform.Visible = False
.IBtrackinglabel.Visible = False
.ScriptTrackinglabel.Visible = False
.cmdOpenDMJIform.Visible = False
.DMJobTrackinglabel.Visible = False
End If
Else
If strUserLevel = 1 Then
.cmdOpenIBTform.Visible = False
.cmdOpenScriptTrackform.Visible = False
.IBtrackinglabel.Visible = False
.ScriptTrackinglabel.Visible = False
End If
End If
End With
End Sub
function of a Form.
It looks up the User Level of the current user
logged in at the time, who should exist in one of 2 tables.
Depending on their assigned UserLevel# determines what
controls they see on the Startup form.
The code works perfectly if the user belongs to one of the
tables, but it gives a "Type Mismatch" error if it can't
find a logged in user. The "ElseIf" statement with
a "MsgBox" function I thought would have helped to take
care of that, but it doesn't.
Can anyone see, judging by the code, why a "Type Mismatch"
would occur. I can't seem to figure it out.
Any help would be appreciated.
Thanks.
Ron (See routine below)
---------------------------------------------------------
Private Sub Form_Load()
Dim strUserLevel As String, strUser As String
strUser = CurrentUser()
strUserLevel = Nz(DLookup
("pUserLevel", "[tblProjectMgrs]", _
"ProjectName=""" & strUser & """"), "")
With Me
If strUserLevel = "" Then
strUserLevel = Nz(DLookup"
tUserLevel", "[refTMSStrategyMgr]", _
"StrategyMgr=""" & strUser & """"), "")
If strUserLevel = 2 Then
.cmdOpenDMJIform.Visible = False
.DMJobTrackinglabel.Visible = False
ElseIf strUserLevel = "" Then
MsgBox "User" & CurrentUser() & "is
not in either table." & _
"Please contact the system Admin to
add you to the appropriate table.", vbOKOnly
.cmdOpenIBTform.Visible = False
.cmdOpenScriptTrackform.Visible = False
.IBtrackinglabel.Visible = False
.ScriptTrackinglabel.Visible = False
.cmdOpenDMJIform.Visible = False
.DMJobTrackinglabel.Visible = False
End If
Else
If strUserLevel = 1 Then
.cmdOpenIBTform.Visible = False
.cmdOpenScriptTrackform.Visible = False
.IBtrackinglabel.Visible = False
.ScriptTrackinglabel.Visible = False
End If
End If
End With
End Sub