Disabled Command Buttons in more than one form (1 Viewer)

melvis

Registered User.
Local time
Today, 18:02
Joined
Aug 2, 2002
Messages
40
Hi all,

I have a frmUserLoginScreen that opens frmMainSelectionScreen, which has 4 command buttons on it. Dependant on user level, some of the command buttons are disabled.

I have four user groups, manager, admin, IT and guest. When the guest logs on, the frmMainSelectionScreen only has one command button enabled. Once clicked, this opens frmClientDetails which has a command button that enables the user to add a record.

Basically, I want the add record command button to be disabled on the frmClientDetails if the user is a guest.

I've tried all sorts of code to reference the other forms but I'm not having any luck. Has any kind fellow got any ideas?

Thanks
 

Mile-O

Back once again...
Local time
Today, 18:02
Joined
Dec 10, 2002
Messages
11,316
Where do you store the user level?

Code:
Forms("FormName").cmdButton.Enabled = False
 

melvis

Registered User.
Local time
Today, 18:02
Joined
Aug 2, 2002
Messages
40
I store the user level in the users table, along with their name and login details.
 

Mile-O

Back once again...
Local time
Today, 18:02
Joined
Dec 10, 2002
Messages
11,316
Sorry, I meant when someone logs in to the database. How do you determine someone's user level?
 

melvis

Registered User.
Local time
Today, 18:02
Joined
Aug 2, 2002
Messages
40
Ahh!

The login form checks against the details stored in the table and then displays the selection screen based on the code situated in the onload event.

It's only a small database that will used by about 6 people so the security is not too advanced.

Should I have a hidden field somewhere in the tables that says who is logged on and then make the command button disabled dependent on this? If so, how would I go about this?
 

Mile-O

Back once again...
Local time
Today, 18:02
Joined
Dec 10, 2002
Messages
11,316
melvis said:
Should I have a hidden field somewhere in the tables that says who is logged on and then make the command button disabled dependent on this? If so, how would I go about this?

Not the tables. Just a hidden control on your login form, or whatever, which you can reference whenever you want to get the user level as illustrated above.
 

ScottGem

Registered User.
Local time
Today, 13:02
Joined
Jun 20, 2005
Messages
1,119
The way I usually implement security is to use their network login. You can find a function here: http://www.mvps.org/access/api/api0008.htm to capture that login. Unless there is an issue about people using other people's machines this can be reasonably secure. This way, the user doesn't have to login or remember another password.

To use this security, you simply use something like this:

If DLookup("[level]", "tblusers", "[UserID] = '" & FOSuserName() & "'") = "Guest" Then

wherever you need to apply your security
 

Mile-O

Back once again...
Local time
Today, 18:02
Joined
Dec 10, 2002
Messages
11,316
Or:

Code:
Dim strUserType As String

strUserType = Nz(DLookup("[level]", "tblusers", "[UserID] = """ & Environ("username") & """"))

Select Case strUserType
    Case Is = "Guest"

    Case Is = "Admin"

    Case Else

End Select
 
Last edited:

Users who are viewing this thread

Top Bottom