Set form as Read-Ony Form
Before restricting a form to user, we need to have a user table with UserSecurity field. In this how to, I will create a lookup table tblSecurityLevel for a UserSecurity field on the tblUser table.
1.) Create a table tblSecurityLevel with a SecurityID and SecurityLevel field and add Admin for SecurityID =1 and User for SecurityID =2
2.) Create a table tblUser with a UserLogin, UserSecurity and Password fields. Setup a table tblWorker that has a UserSecurity field links to a table tlbSecurityLevel. So the data type of a UserSecurity field is number because it refers to the SecurityID (Autonumber) in the tblSecurityLevel table above. You can create the UserSecurity field from the Lookup Wizard on the dropdown of Data Type column.
In this How To, I will show two different methods of creating a read-only form for a regular user: creating a read-only form with database that does not use the Login Form and with database that using a login form.
For Database with no Login Form
We will use a computer login id (network login id) for a UserLogin field in the tblUser table. In this method, a password is not required when open the access database file. The UserLogin matching with a computer login ID will appear on the first form when database opened. The specific form will be opened as Read Only if a UserSecurity type is User depending on a UserLogin. Follow the step below:
Step 1 Under the On Load Event of Navigation Form (first form opened), assign a computer login ID to a variable User then assign a User to textbox TxtLogin shown below.
Private Sub Form_Load() Dim User As String User = Environ("Username") Me.TxtLogin = User End Sub
Step 2 Select a form that you want to make it Read Only to User type of UserSecurity. In this example, I select Task due date tab which has a target name from frmTaskList form.
Step 3 On Load Event of Task due date tab, enter the VBA code below. Or you can put the VBA code on form frmTaskList
Private Sub Form_Load() Dim LoginType As Integer Dim user As String ‘set user = a value of the txtLogin textbox on the Navigation Form user = Forms![Navigation form]!TxtLogin ‘Assign the UserSecurity 1 or 2 from the user login to LoginType LoginType = DLookup("UserSecurity", "tblUser", "UserLogin = '" & user & "'") If LoginType = 2 Then ‘disable if user login type is 2 (regular user) Me.AllowDeletions = False Me.AllowEdits = False Me.AllowAdditions = False End If End Sub
How it works:
After the Task due date tab is clicked, a form frmTaskList is loaded. If the user has a Login Type =2 (the SecurityID of User from table tblSecurityLevel) then frmTaskList form will open and will disable any edition, deletion or adding a new record on form. It is known as Read Only form.
***********************
For Database using a Login Form with Login ID and Password
Step 1: You should have a Login Form looks like picture below already. If you don’t have one you can create it with the instruction on How to Create Login Form or video link here.
Step 2: If you have a Navigation Form open after you logged in then you need to have a textbox “TxtLogin” on the header section of Navigation Form
Step 3: Assign the user login ID from the Login Form to Navigation Form.
Under the Ok button, the code will look like below:
DoCmd.OpenForm “Navigation Form” Forms![Navigation Form]![txtLogin] = LoginID
Full instruction on Create Login Form here.
If you login as jvang then jvang will show on the txtLogin textbox on the Navigation Form
Step 4: Select form that you want to make it Read Only to a User type of UserSecurity. In this example, I select Task due date tab which has a target name from frmTaskList form.
Related Video:
The pills enable good intercourse with your wife and doctor so that you can opt for appropriate solution. cheap viagra Research viagra sale cheap icks.org on the product is essential. Online caverta pills can cialis generic purchase be ordered at innumerable pharmacy. Herbal sexual acquisition de viagra enhancement remedies are made up of herbal ingredients that provide benefits to various other parts of the body.
I like this site very much, It’s a very nice
situation to read and get information and also tips.
I feel this is one of the so much vital information for me.
And i’m glad studying your article. But want to observation on some basic issues, The
website taste is great, the articles is actually nice : D.
Good task, cheers
Lisää: http://ebaddies.com/blogs/78897/329758/sahkotupakka-pelot
Hello There. I found your blog using msn. This is a really well written article.
I’ll be sure to bookmark it and return to read more of your useful
information. Thanks for the post. I will definitely comeback.
I’d like to find out more? I’d want to find out more
details.
more information at youtube video on how to create login form with advance security level at https://www.youtube.com/watch?v=gAKmPnAnXSM
Waay cool! Some very valid points!I appreciate yyou writing this article plus
the rest of the site is also really good.
This piece of writing gives clear idea in support of the
new viewers of blogging, that actually how to
do blogging and site-building.