Tab Control Security

M

Manuel

I have a tab control (with several pages) on a form and I want to be able to
prevent the user from accessing a particular page if the user is not
authorized to do so (I know how to do this part. I retrieve the users’
windows ID and then do a check against a table of authorized users). My
question is where should the code be placed so that it executes and does the
check prior to allowing the user to view the page?

I have the following code in the On Change event of the tab control which
provides a message and then redirects the users to another page, but this
method still allows the user to view the content on the page (although, they
would not be able to change data due to the redirect).

Private Sub MyTabControl_Change()

If Me.MyTabControl.Pages(Me.MyTabControl.Value).Name = "Metrics" then

<call code that checks whether user is authorized to view page. If the user
is not authorized then…>

MsgBox "You do not have access to this tab", vbCritical, "No Access"
DoCmd.GoToControl "ProjectId"

End if

End Sub

The “ProjectId†control is located on another page.

Thank you in advance for your assistance.

Manuel
 
D

Dirk Goldgar

Manuel said:
I have a tab control (with several pages) on a form and I want to be able
to
prevent the user from accessing a particular page if the user is not
authorized to do so (I know how to do this part. I retrieve the users’
windows ID and then do a check against a table of authorized users). My
question is where should the code be placed so that it executes and does
the
check prior to allowing the user to view the page?

I have the following code in the On Change event of the tab control which
provides a message and then redirects the users to another page, but this
method still allows the user to view the content on the page (although,
they
would not be able to change data due to the redirect).

Private Sub MyTabControl_Change()

If Me.MyTabControl.Pages(Me.MyTabControl.Value).Name = "Metrics" then

<call code that checks whether user is authorized to view page. If the
user
is not authorized then…>

MsgBox "You do not have access to this tab", vbCritical, "No Access"
DoCmd.GoToControl "ProjectId"

End if

End Sub

The “ProjectId†control is located on another page.

Thank you in advance for your assistance.


One possibility would be to check the user's authorization in the form's
Open event, and make the page invisible if the user isn't authorized to see
it:

'------ start of example code ------
Private Sub Form_Open(Cancel As Integer)

If <user isn't authorized to see page 4> Then
Me.MyTabControl.Pages(4).Visible = False
End If

End Sub
'------ end of example code ------
 
M

Manuel

Why, that will work perfectly! Thanks!!

Manuel

Dirk Goldgar said:
One possibility would be to check the user's authorization in the form's
Open event, and make the page invisible if the user isn't authorized to see
it:

'------ start of example code ------
Private Sub Form_Open(Cancel As Integer)

If <user isn't authorized to see page 4> Then
Me.MyTabControl.Pages(4).Visible = False
End If

End Sub
'------ end of example code ------

--
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top