Testing for security rights

G

Guest

I have a macro that is called from a switchboard. Runs fine, does everything
I need. My problem is security. I only want people with admin rights to be
able to run these macros. Is ther a way that security rights can be testd in
a macro? I would like for the first step to be the test and if user is is not
authorized, exit macro. Right now the first function puts out a message
'Error in executing this command' and than exits macro. I would like to be
able to send message that 'User does not have permission to run macro'
message.
Any help appreciated.
Thanks
 
N

news.bellnet.ca

Create security form which comes up as soon as the database is started, and
then based on the user/password hides/shows items on the switch board.

Private Sub password_AfterUpdate()
If Me.password <> " " Then
If (Me.user = "1" And Me.password = "0") Or (Me.user = "2" And
Me.password = "2") Then
passwd = 1
Me.Command6.Enabled = True
End If
If (Me.user = "3" And Me.password = "3") Or (Me.user = "4" And
Me.password = "4") Then
passwd = 2
Me.Command6.Enabled = True
End If
If (Me.user = "5" And Me.password = "5") Or (Me.user = "5" And
Me.password = "5") Then
passwd = 4
Me.Command6.Enabled = True
End If
DoCmd.ShowToolbar "Form View", acToolbarNo
DoCmd.ShowToolbar "DataBase", acToolbarNo
If (Me.user = "W" And Me.password = "A") Then
DoCmd.ShowToolbar "Form View", acToolbarYes
passwd = 1
Me.Command6.Enabled = True
End If
Else
Me.user.Value = " "
Me.user.SetFocus
End If
End Sub

Now add the something like this in the switchboard code

Private Sub Form_Open(Cancel As Integer)
If passwd > 1 Then
' Me.Command36.Enabled = False
If passwd > 2 Then
Me.Command29.Enabled = False
Me.Command30.Enabled = False
Me.Command26.Enabled = False
Me.Command19.Enabled = False
Me.Command23.Enabled = False


If passwd > 3 Then
Me.Command25.Enabled = False
Me.Command18.Enabled = False
Me.Command42.Enabled = False
Me.Command57.Visible = True
Me.Command58.Visible = True

End If
End If
End If
If Now >= Me.TIME1 Then
DoCmd.OpenForm "warning"
End If
End Sub

I hope it helps.

Naveed
 
G

Guest

Thanks, with slight modification it looks like it will do the job.
I appreciiate the work you put into the resolution. It was more than I
though it would take.
 

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