check user level then continue dependant

thmsjlmnt3953

Registered User.
Local time
Today, 21:04
Joined
May 20, 2014
Messages
120
Hi,
im trying to check for certain user levels then if criteria is met it will ask to continue then clear a table..

Code:
Private Sub Command9_Click()
If strSecLvl = dev Or admin Or sprvsr Then
If MsgBox("Do you wish to clear the logs?", vbYesNo, "Clear Logs") = vbYes Then
DoCmd.SetWarnings False
DoCmd.RunSQL "Delete * from tblLogs"
DoCmd.SetWarnings True
Me.Requery
Else
MsgBox "Logs not cleared", vbOKOnly, "Not Cleared"
End If
End If
End Sub
 
You have to compare strSecLev in every case. strSecLev = dev Or strSecLev = admin......
 
a better way would be to use a Case statement
I'm assuming "dev", "admin", "sprvsr" are string values, not variables, if the latter then remove the double quotes

Code:
Select Case strSecLvl
    Case "dev", "admin", "sprvsr"
        If MsgBox("Do you wish to clear the logs?", vbYesNo, "Clear Logs") =  vbYes Then
        DoCmd.SetWarnings False
        DoCmd.RunSQL "Delete * from tblLogs"
        DoCmd.SetWarnings True
        Me.Requery
        End If
    Case Else: MsgBox "Logs not cleared", vbOKOnly, "Not Cleared"
End Select

David
 

Users who are viewing this thread

Back
Top Bottom