Question Restricting users from accessing a specific form.

RXX00

Registered User.
Local time
Today, 08:54
Joined
May 24, 2011
Messages
26
Is there as easy way to do this. I have a list of users most are labled "Users" but a few are labled "Admin" and I only want the users labled "Admin" to access 1 specific form.

Any ideas?
 
Do you have the network login of each user listed in the table? If so it is easy to do like this in the command button which would open the form -
Code:
If Nz(DLookup("[AccessLevelFieldNameHere]", "UsersTableNameHere", "[UserIDFieldNameHere]=" & Chr(34) & VBA.Environ("username") & Chr(34)), vbNullString) = "Admin" Then
   DoCmd.OpenForm "FormNameHere"
Else
    MsgBox "You are not authorized to open this form.", vbInformation, "Error"
End If
 
Do you have the network login of each user listed in the table? If so it is easy to do like this in the command button which would open the form -
Code:
If Nz(DLookup("[AccessLevelFieldNameHere]", "UsersTableNameHere", "[UserIDFieldNameHere]=" & Chr(34) & VBA.Environ("username") & Chr(34)), vbNullString) = "Admin" Then
   DoCmd.OpenForm "FormNameHere"
Else
    MsgBox "You are not authorized to open this form.", vbInformation, "Error"
End If

Yes, I have the network log in for each user in the user data table.

I will give this a go.

Thanks

EDIT - What is the Nz part of your code?
 
The NZ is the Null to Zero function (which in this case returns an empty string if there is a null) so you don't get an "Invalid use of Null" error if the user isn't in the table.
 
Split the database and give the users and admin different front ends...

"Stands back and waits for calls of heresay"
 
Split the database and give the users and admin different front ends...

"Stands back and waits for calls of heresay"

That is an option. The one drawback is having to maintain two files - so if one gets a change, the other must get the change. Not too bad for some things but it can get kind of wicked on complex changes. :)
 

Users who are viewing this thread

Back
Top Bottom