Restricted Forms

A

Aurora

I am using Access 2000

I created a Db that is used by several departments.
(Trying to go paperless you know.) Now I would like to
know if I can restrict form entry to a particular person.
I think this would take a password or something but have
no clue even if Access can do this. I am not familiar
with writing programming code. Can this be done? If so
how?

Aurora
 
B

Bruce

There are all sorts of options. Look up "permissions"
and "user level security" in Help. For a sort of casual
security, you could do something like this:
Call the form you want to restrict to one user
frmSecretForm. Make a new form (frmPassword). Set its
Pop-Up and Modal properties to Yes. Place an unbound text
box (txtPassword) on the form. Place a command button on
the form, with the following code in the Click event:
If Me.txtPassword = "SecretWord" Then
DoCmd.OpenForm "frmSecretForm"
Else
MsgBox "Invalid password",_
vbInformation, "Password Error"
DoCmd.Close acForm, "frmSecretForm"
End If

DoCmd.Close

Underscore in the above code means no line break. Just
leave it out when you write the code.

You could also put a button on frmPassword with the code:
DoCmd.Close acForm, "frmSecretForm"
DoCmd.Close

This will close the form without error messages should
somebody click by mistake on the button to open
frmSecretForm.

Finally, at the command button that opens frmSecretForm,
place the following code:

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmSecretForm"
DoCmd.OpenForm stDocName, , , stLinkCriteria

The code above uses "SecretWord" as the password, so
change it accordingly. Same for the form names, of course.

This method is not really all that secure, since users who
know what they are doing could sneak in and get the
password from the code.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top