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
Microsoft Access

Avatar of undefined
Last Comment
PatHartman

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
PatHartman

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
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
PatHartman

It works for me.  Please post your code.
hassan momo

ASKER
when i put the code and open the form it give me run-time error when i press debug it highlights this codewhen i put the code and open the form it give me run-time error when i press debug it highlights this code
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
PatHartman

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.