R
Ron
I have this Dlookup routine attached to the OnLoad
function of a Form.
The User Level of the current user is checked against a
table at the time they login, this person should exist in
one of 2 tables.
Their assigned UserLevel# determines what controls they
see on the Startup form.
The code works fine if the user belongs to one of the
tables, but it errors out when it can't find a user on one
of the lists. I figured the "ElseIf" statement with the ""
value and the proceeding "MsgBox" function would have
helped to take care of that, but it doesn't.
I can't seem to figure out what is exactly wrong. I've
tried different If..Then scenarios and nothing seems to
work properly.
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.
The User Level of the current user is checked against a
table at the time they login, this person should exist in
one of 2 tables.
Their assigned UserLevel# determines what controls they
see on the Startup form.
The code works fine if the user belongs to one of the
tables, but it errors out when it can't find a user on one
of the lists. I figured the "ElseIf" statement with the ""
value and the proceeding "MsgBox" function would have
helped to take care of that, but it doesn't.
I can't seem to figure out what is exactly wrong. I've
tried different If..Then scenarios and nothing seems to
work properly.
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