Link to home
Start Free TrialLog in
Avatar of hassan momo
hassan momo

asked on

Help to use AllowAdditions, AllowDeletions and AllowEdits

Dear friends,

Please, I want to use AllowAdditions, AllowDeletions and AllowEdits for a form of mine, but I just don't

know how to create a VB code to do it.

Here's my case...
I have a form I use to enter the username and his password, I'm gonna call it "frmlogon".

The frmlogon has:

- a combobox with a dropdown to choose a username;
- a textbox for the password input;
- when i press enter it verifies the username/password confirmation and then opens the MainForm (if password matches, offcourse! If not, there's a MsgBox for it.)

I've already done this! It's working pretty fine! The point is... Each username has a kind of "permission" to handle the MainForm.
i have a table named "tblUsers"
uUserID      uFirstName      uLastName      uPassword      uSecurityID
1      reception            ***      1
3      ADMIN            ***      9
6      security            ***      1
so if you please i want
Users with uSecurityID 1 - Can add only
Users with uSecurityID 9 - Can add and edit and delete.
Users with uSecurityID 8 - Can add only
or any other way regardless the uSecurityID
How do I do that? I've seen something like this...
If intUserID = 1 Then
Me.Form.AllowAdditions = True
Me.Form.AllowDeletions = True
Me.Form.AllowEdits = True
ElseIf intUserID = 2 Then
Me.Form.AllowAdditions = True
Me.Form.AllowDeletions = True
Me.Form.AllowEdits = False

But I confess, I didn't understand how to use it, how to design the code structure.
Please, if someone could help me, I would really appreciate it.
i attached the database and the password for any user is 123
Thanks everyone for your attention.
security-database-test.accdb
ASKER CERTIFIED SOLUTION
Avatar of PatHartman
PatHartman
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of hassan momo
hassan momo

ASKER

thank you a lot for your reply but when i use the above code for add or deletions in Form_Load event for login form or any sub form i got error. any ideas
It works for me.  Please post your code.
User generated imagewhen i put the code and open the form it give me run-time error when i press debug it highlights this code
I guessed at the name of your login form.  If you examine the highlighted line, you will see that the form name I chose is different from your actual form name.  Change that line of code to match your form name and your control name.