Form protected by password

rockyjr

Registered User.
Local time
Today, 16:49
Joined
Mar 12, 2008
Messages
100
Hi everyone,

Thank you for everyone that helped me before, I'm getting better eveyday because of you. :cool:

I would like to protect a form with a password. Can anyone point me how I could do this. I do have a password when accessing the database. But, I would also like one for a Form.

Access 2007

Lucas
 
At its simplest:

Code:
If InputBox(...) = "YourPassword" Then
  'Open the form
Else
  Msgbox "Sorry Charlie"
End If
 
That's good thank you.
 
Form Password

Hi
I like this your response
can i use this code in access 2003 where in the form properties do i put this
code
thanks in advance for your all help
 
Password On A Form

Hi
i have used the code and its works just fine, but when i try to use a blank password or wrong password i get the message "sorry wrong password" but i click ok its opens the form.
what i add to prevent the form from opening when a user uses a wrong or blank password?
Thanks
 
I changed it a little bit.

I went to the button that I created, and under the onclick event, I selected code builder and entered this :

Code:
Dim PassWord As String
   PassWord = InputBox("Enter Password")
   If PassWord = "enter your password here" Then
      ' Open Form
      DoCmd.OpenForm "the form name here"
      Else
      MsgBox ("You're not authorized")
   End If

That works perfectly.
 
Rocky, glad you got it going the way you wanted.

jonamua; the open form code must be in the first portion of the If/Then, as in my psuedo-code and Rocky's working code. If you're still having trouble, post your code.
 
What if you have a table with a list of staff user IDs and their passwords?
Can this be looked up so that the user is identified and only the password for that user will open the form?

Renoir
 
but by itself that wond do anything

this needs to be in the form's OPEN event.

if the password is wrong then do

cancel=vbcancel
exit sub

THAT will stop the form opening

----------
so

Code:
sub form_open(cancel as integer) 
dim passwordcorrect

'passwordcorrect = result_from_checking_password
if not passwordcorrect then
  cancel = vbcancel
  exit sub
end if

end sub
 

Users who are viewing this thread

Back
Top Bottom