Enable/Disable buttons (Add, Delete) depending on criteria (1 Viewer)

brunces

Registered User.
Local time
Today, 10:36
Joined
Sep 12, 2004
Messages
45
Friends,

Please, anybody knows if there's any way to configure permissions (add, edit, delete records) without using MS Access default Group/Users Security Accounts?

Because of particular reasons, I've created a self login system for a DB of mine, I mean, it has a table with names, passwords and levels of permission and a LOGIN form which appears when the DB is opened. A VBA code verifies the username and password typed in it and lets users have access or not to the DB. Therefore, I'm not using the default security accounts provided by MS Access.

But this operation is causing me some problems with "permissions", for example...

What if I want to allow a "level 2 user" to add records in a form, but not edit or delete any record?

Using the default security accounts (Access) it's possible to do it. But how could I do that without using it?

I tried to create different forms (based on a single one) with buttons Add and Delete enabled or disabled, depending on the level of the user logged in.

For example...

A "level 3 user" can add and edit records, but cannot delete records. So, the form opened for him has the "Delete button function" disabled. The button exists in the form, but it has no function, no utility. It's really disabled. (I could've even removed the button from the form, but I didn't want to.)

Other example...

A "level 4 user" can only "edit" existing records, I mean, he cannot add or remove records. So, the form opened for him nas the "Add button function" and the "Delete button funcion" disabled. The buttons exist in the form, but they has no function, no utility. They're disabled.

This is a way I found to solve the problems with permissions. But it's getting hard to go on with it, because forms must be duplicated according to the number of levels the DB has. And the file is getting bigger and bigger.

Maybe there's a way to disable a button depending on a criteria... If so, that would be nice, for it wouldn't be necessary to duplicate forms according to the number of levels. There would be a single form and its buttons would be enabled or disabled, depending on the user logged in. Is this possible?

So, anyone knows another way to configure permissions, without using MS Access default security accounts?

I tried to describe what I need here, but if for some reason I didn't make myself clear, please, ask me about what you didn't understand and I'll try to explain it better, OK?

I appreciate your attention, fellas!

Hugz,

Bruno
 

Malcy

Registered User.
Local time
Today, 14:36
Joined
Mar 25, 2003
Messages
586
The real answer probably is to change your security model but as just a thought, if you are holding the level of authority in a table within the database you might try something along these lines - they are just quick thinking but might be worth exploring

Dim intAuth as Integer
intAuth = DLookup("lngAuthorityLevel", "tblAuthority", "Me.txtUserId = tblAuthority.UserId")
If intAuth = 3 or intAuth = 2 or intAuth = 1 then
Me.cmdEditRecord.visible = False
Me.cmdDeleteRecord.visible = False
Else
Me.cmdEditRecord.visible = True
Me.cmdDeleteRecord.visible = True
End If

Obviously field names and table names are all made up and the last part of the DLookup is literal rather than precise but I it might be worth exploring.
You would probably need some code to cover there not being a match
HTH
 

yhgtbfk

Registered User.
Local time
Today, 23:36
Joined
Aug 30, 2004
Messages
123
brunces said:
This is a way I found to solve the problems with permissions. But it's getting hard to go on with it, because forms must be duplicated according to the number of levels the DB has. And the file is getting bigger and bigger.

So, anyone knows another way to configure permissions, without using MS Access default security accounts?

Hehehe, you remind me of what I did before I fully understood Access.

I wanted a vehicle report for each day (ie-Vehicles booked out on 1st January), so I created, manually and painstakingly, 365 reports, one for each day. I got up to November 20th, complained to a friend at dinner, who told me to simply use the WHERE condition, and I spent the whole night embarressed.

What I do, as Malcy suggests, is to create your own security by turning things on and off.

Create a form with everything, but make some controls invisible, and turn off the ability to delete or edit records.

Then simply do

securityNumber = dlookup("securitynumber", "staff", "username = '" & username & "'")

select case securitynumber
case 1
..........Some code
case 2
..........etc...

Things like

textbox.visible = True/False
textbox.locked = true/false
textbox.enabled = true/false

etc....
 

rmistry

New member
Local time
Today, 14:36
Joined
Oct 3, 2012
Messages
1
I am using Access 2010 and I need some help on disabling a button based on a form which is based on a table with a hidden value (Hidden as in not displayed).

All I want to do is disable the button if the value is null.

Which event should this be on, as the form is a continuous form type.
I have the following but it does not work. Please help.

I am trying this on the Form level property ‘On Current’, is this right place to put this first of all and please help correct the code



Private Sub Form_Current()

If IsNull(DLookup("BDOID", "tblInvOpp")) = False Then
Forms!frmInvOppSummaryData!cmdOpenBusDevOpForm.Enabled = True
Else
Forms!frmInvOppSummaryData!cmdOpenBusDevOpForm.Enabled = False
End If
 

pkgicwa

New member
Local time
Today, 19:06
Joined
Aug 12, 2015
Messages
1
Friends,

Please, anybody knows if there's any way to configure permissions (add, edit, delete records) without using MS Access default Group/Users Security Accounts?

Because of particular reasons, I've created a self login system for a DB of mine, I mean, it has a table with names, passwords and levels of permission and a LOGIN form which appears when the DB is opened. A VBA code verifies the username and password typed in it and lets users have access or not to the DB. Therefore, I'm not using the default security accounts provided by MS Access.

But this operation is causing me some problems with "permissions", for example...

What if I want to allow a "level 2 user" to add records in a form, but not edit or delete any record?

Using the default security accounts (Access) it's possible to do it. But how could I do that without using it?

I tried to create different forms (based on a single one) with buttons Add and Delete enabled or disabled, depending on the level of the user logged in.

For example...

A "level 3 user" can add and edit records, but cannot delete records. So, the form opened for him has the "Delete button function" disabled. The button exists in the form, but it has no function, no utility. It's really disabled. (I could've even removed the button from the form, but I didn't want to.)

Other example...

A "level 4 user" can only "edit" existing records, I mean, he cannot add or remove records. So, the form opened for him nas the "Add button function" and the "Delete button funcion" disabled. The buttons exist in the form, but they has no function, no utility. They're disabled.

This is a way I found to solve the problems with permissions. But it's getting hard to go on with it, because forms must be duplicated according to the number of levels the DB has. And the file is getting bigger and bigger.

Maybe there's a way to disable a button depending on a criteria... If so, that would be nice, for it wouldn't be necessary to duplicate forms according to the number of levels. There would be a single form and its buttons would be enabled or disabled, depending on the user logged in. Is this possible?

So, anyone knows another way to configure permissions, without using MS Access default security accounts?

I tried to describe what I need here, but if for some reason I didn't make myself clear, please, ask me about what you didn't understand and I'll try to explain it better, OK?

I appreciate your attention, fellas!

Hugz,

Bruno
Dear Bruno
Can you please tell me or send me login system developed by you with tables and forms
I appreciate you attention
Pavan ,India
 

Users who are viewing this thread

Top Bottom