Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passwording forms?! HELP! 4

Status
Not open for further replies.

joe2kuk

Technical User
Oct 14, 2002
29
GB
Does anyone know how to password forms on access 2k/XP? If not then let me know that you can't. Please help!
 
Hi:
Here's a stopgap that I used on a button that opened one form from another:
Code:
Private Sub NameOfControl_MouseUp(Button_ 
    As Integer,_
    Shift As Integer, X As Single, Y As Single)
  Dim stDocName As String
  Dim stLinkCriteria As String
  Dim theanswer As String
On Error Resume Next
  DoCmd.Beep
  theanswer = InputBox("Temporarily_ 
    access to editing raw data will be_
    limited. Therefore, Please Enter Password")
  If theanswer = "purplepeopleeater" Then
    stDocName = "NameOfFormToPassword"
    DoCmd.OpenForm stDocName, , , stLinkCriteria,_
      acFormEdit
    Else
      'Answer incorrect
      DoCmd.CancelEvent
      DoCmd.Beep
      MsgBox "Password Incorrect"
    End If
End Sub

The user has to enter the password "purplepeopleeater" to gain access to the form.

This is not cool! I need to change this procedure...but you sounded desperate. "Please help!" always gets my empathy enzymes raging.

There are FAQ's on this form that address security. There are procedures on Microsoft's web site. There are white papers written on the subject. Gus Brunston [glasses] An old PICKer, using Access2000.
 
If I edit the password in the Code will it work? Will it also work with other macro's, if it works thats still a HUGE help.

THANKS!!!!!!!!!!!
 
Do you have user level security set up on the database ?

If you do you can easily allow access to specific forms based on membership of a specific Group.


( Setting up User/Group security from scratch ( especially if you've not done it before ) is NOT the sort of thing to take on in a panic with a deadline looming. But in the long term is IS the way to go. )



G LS
accessaceNOJUNK@valleyalley.co.uk
Remove the NOJUNK to use.

Please remember to give helpful posts the stars they deserve!
This makes the post more visible to others in need! :-D

 
The code din't work, I can't find out where as one of my progamers said that it looks ok but I need to speak to someone else who's is an Access expert. I wont see him untill next week it their any way I can add a password?

E.G. Using a macro "openForm" and putting a code in "where condition"

Thanks

[morning]
 
Go to the code AS YOU IMPLEMENTED IT and copy it and post it here and we'll see where you've added the typo in.

As a QD fix Gus's code will work fine as long as you change the object names correctly.

Also, it would help if you'd tell us which line the code breaks on.
To find that out comment out the On Error line.
'On Error Resume Next



G LS
accessaceNOJUNK@valleyalley.co.uk
Remove the NOJUNK to use.

Please remember to give helpful posts the stars they deserve!
This makes the post more visible to others in need! :-D

 
there is another way of setting up a user name for a form but it requires a bit of work.

Step one
create a table called table1
it doesn't matter what fields are in the table just
as long as you set up a field for a username and a value associated with the username if you just want a password and no username then just add password field or both fields if you want.
now that you have all the fields in place you create a query based on table 1

Step two
Once you have the query in place you go to the design view portion of the query and under username or password you enter some text surrounded by bracetes for example:
[Please Enter Username]
this would go under Username

Step three

Create a form that is linked to the query
make sure in the form you have set up the username, password and value field(note all of the fields can be invisible and can be placed anywhere on the form.
Step four

Create a macro
and in the macro under condition

you enter

[value] is null

and under action you put down
close and what ever the name of the form is

or
[value] = 1
Action= Open Form

so that for every username you enter there has to be a value assocaiated with it, it could all be the same value like everyone could have a value of one or two.

Step 5

Now that you have the macro set up you will go back to the form's design view and go to the on open part of the form and attach the macro now when you click on the form you should see a box asking for either the username or password.


Note:
You can bypass the security feature of this if you press shift at the same time the you click on the form but not too many people know about this so if your users aren't computer savy you can get away with this or you can probably find some code that will disable it.

let me know if this helps you
 
Private Sub Doctors_Click()
As Integer,_
Shift As Integer, X As Single, Y As Single)
Dim stDocName As String
Dim stLinkCriteria As String
Dim theanswer As String
On Error Resume Next
DoCmd.Beep
theanswer = InputBox("Temporarily_
access to editing raw data will be_
limited. Therefore, Please Enter Password")
If theanswer = "purplepeopleeater" Then
stDocName = "doctors"
DoCmd.OpenForm stDocName, , , stLinkCriteria,_
acFormEdit
Else
'Answer incorrect
DoCmd.CancelEvent
DoCmd.Beep
MsgBox "Password Incorrect"
End If
End Sub
 
The following lines endup red or highlited:

2,4,9,10,11,14 and Private Sub Doctors_Click()
is highlited yellow,

I can see my access expert today if he's not to busy but he's working on a bigger project, if you can help please do!
 
Well the first line should be

Private Sub Doctors_Click(Button _

and ALL of the line continuation underscore characters need a space character BEFORE them.



Then lets see what is lets when you sort those out.


G LS
accessaceNOJUNK@valleyalley.co.uk
Remove the NOJUNK to use.

Please remember to give helpful posts the stars they deserve!
This makes the post more visible to others in need! :-D

 
Thanks, I have a meeting with someone who is the best we’ve got at writing codes, so he should get all the bugs out.

If he can't sort it I've got a problem.

He might even write his own code for me to use, if so I'll post it.
 
I Guess This Is An Easy One,

Dim x As Integer
Option Compare Database

Private Sub Form_Activate()
x = 0
End Sub

Private Sub txtpass_AfterUpdate()
Dim stDocName As String
Dim stLinkCriteria As String

If txtpass = "****" Then
DoCmd.Close
stDocName = "Form Name"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Else
x = x + 1
txtpass.SetFocus
End If
If x = 3 Then
DoCmd.Close
End If
End Sub

Best Regards
Haitham
 
Thanks I'll test that tommoro, can't now as the computer Im on hasn't got access.

Cheers mate!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top