Question about a exit butten and Admin rights

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hallo

I hope some one can help me I have a exit button and when the person click
on it I want access to see is this user a admin user or not and if admin yes
then run a delete query if not admin user then don’t run the query and just
exits.

Thank you
Markus
 
You could try something like this

Dim objUser As User
For Each objUser In DBEngine.Workspaces(0).Groups("Admins").Users
If objUser.Name = CurrentUser Then
CurrentDb.Execute "QueryName", dbFailOnError
End If
Next

Instead of the above, you may want to place this in the Load event of the
form and enable or disable the button.

Dim objUser As User
For Each objUser In DBEngine.Workspaces(0).Groups("Admins").Users
If objUser.Name = CurrentUser Then
Me.cmdDeleteQueryButton.Enabled = True
Exit Sub
Else
Me.cmdDeleteQueryButton.Enabled = False
End If
Next
 
HI

I have tryd it and i receive the error

User-defined type not defined

here is the code
Private Sub Exit_Click()
On Error GoTo Err_Exit_Click

Dim objUser As User
For Each objUser In DBEngine.Workspaces(0).Groups("Admins").Users
If objUser.Name = CurrentUser Then
CurrentDb.Execute "Delete Old Cards", dbFailOnError
End If

Forms![Switchboard]!Logoff = Now()
DoCmd.Quit

Exit_Exit_Click:
Exit Sub

Err_Exit_Click:
MsgBox Err.Description
Resume Exit_Exit_Click

End Sub

What am i doing wrong
 
That's DAO code. You must be using Access 2000 or 2002, which, by default,
don't have a reference set to DAO.

With any code module open, select Tools | References from the menu bar,
scroll through the list of available references until you find the one for
Microsoft DAO 3.6 Object Library, and select it.


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Markus said:
HI

I have tryd it and i receive the error

User-defined type not defined

here is the code
Private Sub Exit_Click()
On Error GoTo Err_Exit_Click

Dim objUser As User
For Each objUser In DBEngine.Workspaces(0).Groups("Admins").Users
If objUser.Name = CurrentUser Then
CurrentDb.Execute "Delete Old Cards", dbFailOnError
End If

Forms![Switchboard]!Logoff = Now()
DoCmd.Quit

Exit_Exit_Click:
Exit Sub

Err_Exit_Click:
MsgBox Err.Description
Resume Exit_Exit_Click

End Sub

What am i doing wrong
Wayne Morgan said:
You could try something like this

Dim objUser As User
For Each objUser In DBEngine.Workspaces(0).Groups("Admins").Users
If objUser.Name = CurrentUser Then
CurrentDb.Execute "QueryName", dbFailOnError
End If
Next

Instead of the above, you may want to place this in the Load event of the
form and enable or disable the button.

Dim objUser As User
For Each objUser In DBEngine.Workspaces(0).Groups("Admins").Users
If objUser.Name = CurrentUser Then
Me.cmdDeleteQueryButton.Enabled = True
Exit Sub
Else
Me.cmdDeleteQueryButton.Enabled = False
End If
Next
 
Back
Top