Function DisplayMenu(UserId As Variant, WW As String, frm As Form)
' at this stage the userId and access level has been checked
Dim FinishDate As Date, tmpDate As Date, PasswordPeriod As Date
Dim CheckPassword As String, strMsg As String
Dim strSQL As String, sFilter As String
Dim ValidUser As Integer, AccessLevel As Integer
Dim Actief As Boolean, PJK As Boolean
Dim rst As DAO.Recordset
Dim tmpVar As TempVar
ValidUser = 2
' *****************************************************************************************************************
' validate user_id
' *****************************************************************************************************************
strSQL = "SELECT [medewerkerID], [inlognaam], [medewerker_naam], [Wachtwoord], [rechten], [WW_Datum], " _
& "[Actief] FROM tMedewerkers WHERE [medewerkerID] = " & UserId
Set rst = CurrentDb.OpenRecordset(strSQL)
With rst
.MoveLast
.MoveFirst
If .RecordCount = 1 Then
ValidUser = 2
If .Fields("Wachtwoord") = WW Then
AccessLevel = !rechten.Value
Actief = !Actief.Value
If IsNull(.Fields("[WW_Datum]")) Then
tmpDate = DateAdd("yyyy", -1, Date)
Else
tmpDate = .Fields("[WW_Datum]").Value
End If
PasswordPeriod = tmpDate
ElseIf IsNull(.Fields("Wachtwoord")) Or .Fields("Wachtwoord") = "welkom" Then
ValidUser = 5
Else
If sUserID = sUserID_ori Then
iPW_Count = iPW_Count + 1
Else
iPW_Count = 1
End If
ValidUser = 1
AccessLevel = 3
End If
Else
ValidUser = 0
End If
.Close
End With
' *****************************************************************************************************************
' validate access_level
' *****************************************************************************************************************
Select Case ValidUser
Case 0, 1
If iPW_Count < 3 Then
strMsg = "Geen toegang tot Database; " & vbCrLf _
& "Je hebt een verkeerd wachtwoord ingetypt." & vbCrLf _
& "Je hebt nog " & 3 - iPW_Count & " poging(en)."
MsgBox strMsg, vbInformation, "ONGELDIGE INLOGPOGING"
Exit Function
Else
DoCmd.Quit
End If
Case 2
' validate password expiry
If PasswordPeriod < DateAdd("m", -3, Date) Or IsNull(PasswordPeriod) Then
strMsg = "Je wachtwoord is verlopen. Je moet het wachtwoord eerst veranderen."
MsgBox strMsg, vbInformation, "Verlopen wachtwoord"
sFilter = "MedewerkerID= " & UserId
frm.Visible = False
DoCmd.OpenForm "f_change_password", acNormal, , , , acDialog, sFilter
frm.Visible = True
Else
DoCmd.Close acForm, frm.Name
'-----------------------------------------------------------------------------------------------------
'Startformulier openen
'-----------------------------------------------------------------------------------------------------
DoCmd.OpenForm "Startformulier"
If Not TempVars("varCheckTempVars").Value & "" = "" Then TempVars("varCheckTempVars").Value = False
End If
Case 5
' validate password expiry
strMsg = "Je heeft nog geen wachtwoord ingevoerd. Je moet eerst een wachtwoord invoeren."
MsgBox strMsg, vbInformation, "Geen wachtwoord"
sFilter = "MedewerkerID= " & UserId
frm.Visible = False
DoCmd.OpenForm "f_change_password", acNormal, , , , acDialog, sFilter
frm.Visible = True
Case Else
strMsg = "Geen toegang" & vbCrLf & "Neem contact op met de Administrator als het probleem blijft bestaan."
MsgBox strMsg, vbInformation, "ONBEKENDE GEBRUIKER OF WACHTWOORD"
End Select
Exit Function
err_display_menu:
MsgBox Err.Description
End Function