Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I ask the database , what k

Status
Not open for further replies.

Informatic

Programmer
Oct 4, 2002
34
DE
How can I ask the database , what kind of user the current user is --- Administrator or just an User.
If he is no Administrator then he couldn't see the VBA Code else he can see all the tables,forms and the VBA Code.
Have somebody wrote such a VBA Code.

Or is there some good web sites for Access security...

Please...
 
You might be able to modify this Function to your needs. You can only run this function if you are in the Admins Group.

Paul

Function IsUserInGroup(strGroup As String, strUser As String) As Integer
' Returns True if user is in group, False otherwise
' This only works if you're a member of the Admins group.
Dim ws As Workspace
Dim grp As Group
Dim strUserName As String

Set ws = DBEngine.Workspaces(0)
Set grp = ws.Groups(strGroup)
On Error Resume Next
strUserName = ws.Groups(strGroup).Users(strUser).Name
IsUserInGroup = (Err = 0)
End Function
 
Here's a function that any user can run. I think I stole it from MS.

But it actually sounds like you should do some reading on Acccess security. Get the White Paper from MS Access. It will tell you everything you need to know. But most people have to read it four times before they understand it. Don't worry. Just really read it four times. Then you'll get it all.

Public Function IsUserInGroup(sUser As String, sGroup As String) As Boolean
On Error GoTo Error
Dim ws As Workspace
Dim uUser As User
Dim iCount As Integer

Set ws = DBEngine.Workspaces(0)
Set uUser = ws.Users(sUser)
IsUserInGroup = False
For iCount = 0 To uUser.Groups.Count - 1
If uUser.Groups(iCount).Name = sGroup Then
IsUserInGroup = True
End If
Next iCount
Exit Function
Error:
ErrorTrap Err.Number, Err.Description, "IsUserInGroup"
End Function =============
Jeremy Wallace
Designing, Developing, and Deploying Access databases since 1995.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top