We help IT Professionals succeed at work.

Help to use AllowAdditions, AllowDeletions and AllowEdits

hassan momo
hassan momo asked
on
125 Views
Last Modified: 2017-11-20
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
Comment
Watch Question

CERTIFIED EXPERT
Distinguished Expert 2017
Commented:
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION

Author

Commented:
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
CERTIFIED EXPERT
Distinguished Expert 2017

Commented:
It works for me.  Please post your code.

Author

Commented:
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
CERTIFIED EXPERT
Distinguished Expert 2017

Commented:
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.

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions