By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,581 Members | 2,023 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,581 IT Pros & Developers. It's quick & easy.

Simple login form w/ different permissions?

P: 70
I'm trying to create a very simple login form. I need it to have a text box where a user can enter a password and login to the db. At which point, they'd have full access to read data, edit data, add new records, or delete old records.

Or, if a user does not know the password, they can press a button to login w/ read only rights (and thus not be able to edit any data).

I realize this isn't extremely secure but we need it mostly to make it harder for people to do something they shouldn't be doing. For this small database, a simple login form will do.

I can create the form easily. What I'm confused about his how exactly to enable or disable write access. Currently, I have one main form which displays records in single form view. Then I have a subform (which isn't linked to main form) which will display records in datasheet view. Then a user can edit records in the single form and hit save. Or, they can add new records and hit save. If a user doesn't have the password, I need the text boxes and combo boxes to be locked and the save button should also be locked.
Apr 12 '16 #1
Share this Question
Share on Google+
4 Replies


NeoPa
Expert Mod 15k+
P: 31,561
In such a case your whole database, and I guess I'm really talking about all the forms that handle showing and updating of data, needs to be designed to reference where you store the value indicating whether the user signed in or not and handle disabling of this property for each such form.

The important properties are :
AllowEdits; AllowAdditions & AllowDeletions.

Be careful with the simpler RecordsetType as setting it to Snapshot will have an extra effect of disabling the showing of updates from other sources too.
Apr 12 '16 #2

P: 70
Thanks for the fast reply NeoPa!

Thus far, I have built a simple login form which contains a text box for the user to enter a password, a text box which contains the password (and is hidden), and two buttons.

There's a Login button which makes sure that the entered password matches what's stored in the text box. If they match, it opens a form.

Then I have a button which opens the same form like this:

DoCmd.OpenForm "Ciber_ITT_ResponseForm", DataMode:=acFormReadOnly

That opens the form in read only mode and the user is not allowed to make any edits. Not sure exactly what acFormReadOnly does. I assume it sets AllowsEdits to false.

Right now I need to figure out how to hide a couple buttons if the form is opened in read only mode.
Apr 13 '16 #3

PhilOfWalton
Expert 100+
P: 1,430
This is slightly long winded just depends exactly on what you mean by readonly.
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Open(Cancel As Integer)
  2.  
  3.     If Me.AllowEdits = False And Me.AllowAdditions = False And Me.AllowDeletions = False Then
  4.         Btn1.Visible = False
  5.         Btn2.Visible = False
  6.     End If
  7.  
  8. End Sub
  9.  
Phil
Apr 13 '16 #4

NeoPa
Expert Mod 15k+
P: 31,561
ITTechGuy:
Not sure exactly what acFormReadOnly does.
Well, here's a link that explains it pretty well (OpenForm Method). You'll have to click on the "AcFormOpenDataMode" link.

ITTechGuy:
Right now I need to figure out how to hide a couple buttons if the form is opened in read only mode.
As you guessed, and confirmed by reading the link, one of the settings it resets to false is AllowEdits. Thus, when the form opens (Form_Load() or Form_Open()), check that setting to determine if the form was opened that way or not.
Apr 13 '16 #5

Post your reply

Sign in to post your reply or Sign up for a free account.