I have a form with a tab control on it. I only want one of the tabs to be accessible to certain people, and to display an "Access Denied blah blah..." MsgBox to those who are not authorized to view the tab. I have that working, properly, which brings me to my problem. For those who are not authorized to access the tab, I would like to kick them back to whichever tab they were most recently on.
The only thing I have been able to come up with is to kick users back to a specific tab that I have coded...
Here is what I have so far:
CODE
Private Sub tabMain_Change()
'Display error message if users attempt to go to OP tab
If Me.tabMain.Value = 5 Then
If Me.txtUserName <> "Robert Grazia" Then
Me.tabMain.Value = 0
MsgBox ("Access Denied")
End If
End If
End Sub
'Display error message if users attempt to go to OP tab
If Me.tabMain.Value = 5 Then
If Me.txtUserName <> "Robert Grazia" Then
Me.tabMain.Value = 0
MsgBox ("Access Denied")
End If
End If
End Sub
As you can see, when a user without proper access attempts to click this particicular tab, this code displays a MsgBox and kicks them back to the very first one.
Is there any way to write this code to send users back to whichever tab they were on?
Any help is greatly appreciated! As always, feel free to ask for any additional details!
Robert