470,822 Members | 1,370 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,822 developers. It's quick & easy.

Simple login form w/ different permissions?

70 64KB
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
4 1001
32,311 Expert Mod 16PB
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
70 64KB
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
1,430 Expert 1GB
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)
  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
  8. End Sub
Apr 13 '16 #4
32,311 Expert Mod 16PB
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.

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.

Similar topics

1 post views Thread by nabil m | last post: by
8 posts views Thread by Harris Kosmidhs | last post: by
3 posts views Thread by matheussousuke | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.