Re: Restricting access to database using forms




Hello Carl,

Thanks for your reply. Is there any direct way through this. Is it possible
to compare for values of the username and his password and if it matches than
allow read only access to all forms or in my case only give access to 2 forms
which queries values from tables which the user needs to access.

Can this be done with some vba coding. Also as mentioned the access security
wizard already created user groups like read only users, full permission
users etc. so is it required to add a feild in my authorization table to make
this work.

would appreciate your comments on the above.


"Carl Rapson" wrote:

"vandy" <vandy@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:F9D32833-364A-41EA-A1EC-CAB767724231@xxxxxxxxxxxxxxxx
Hi All,

I have created a database in access2003 and given selective restrictive
access to users using the security wizard.

I have a user who is not on the network and thus not able to access the
workgoup and secruity mdw files which i have created.

I have created a user login form which checks for user name and password.
Private Sub btnlogin_Click()

If IsNull(Me.quserid) Then
MsgBox ("You Must Enter a Valid User ID !!")
Exit Sub

Else

If IsNull(Me.qpwd) Then
MsgBox ("You Must Enter a Password!!")
Exit Sub

End If
End If

If Me.qpwd.Value = DLookup("PWD", "Authorized", "UserID ='" &
Me.quserid.Value & "'") Then

DoCmd.OpenForm "MainMenu", acNormal
Else
MsgBox ("Invalid Password!Try Again!")
End If
End Sub


Question: How to modify this to enable read only acess to all forms and
screens to a selective user x who is not on the windows network.

Right now i want the user to login in using the login form and when he
types
in his username and pwd all the screens and forms should be read only.

can this be done. Thanks in advance.

It can be done, but it will require some VBA coding. You will first need to
add a field to your Authorized table to indicate whether the user is
read-only. Fetch that value, and then pass something in the OpenArgs
parameter of OpenForm to tell the form to make itself read-only. In the
form's Open event, check the contents of OpenArgs and if it's appropriate,
you can either set the form's Allow Additions, Allow Deletions, and Allow
Edits properties to No (essentially rendering the entire form read-only), or
you can loop through the form's controls (using the Controls collection) and
set each control's Locked property to Yes. I usually do the latter, because
it gives me more granular control over the form; I can leave some controls
unlocked, for example (like a combo box for selecting a record to view).

Look in Access help for the Controls collection for examples of how to
iterate through it and how to use the ControlType property to tell what kind
of control it is. You can also search these newsgroups for more information
on OpenArgs, the Controls collection, and ControlType property.

Carl Rapson



.


Loading