Passworded Form control

RaptureReady

Registered User.
Local time
Today, 15:56
Joined
May 7, 2007
Messages
30
Here's a question: I have a form that has 2 control buttons, which open 2 other forms. The thing I want to do is put a password on the control buttons. Is this possible and if so, can you tell me how please?

RR
 
check the samples on this already been done

- good hunting - I can accross this about 6 months ago - and cannot rememeber what it was under .

g
 
A quick example in the click event of the button to open the report:

Code:
Dim strInput As String

strInput = InputBox("Please Enter the Password", "Enter Password")

If strInputBox = "YourPasswordHere" Then
   DoCmd.OpenForm "YourFormNameHere", acNormal
Else
   If MsgBox("You entered the wrong password.  Do you wish to try again?", vbQuestion + vbYesNo, "Password Error") = vbYes Then
       Go to 0
End If
 
Bobs gone and done what i usually do -

its forms your after and not reports
(I usually do this )

in one of the samples there is a click button - up pops a password - psssord entry/failure

now this is not 100% secure cos' if you knwo a bit off access you can get round it - design view - over type code etc ...
but this is still clever
 
check the samples - under oldsoft as the handler - and its red soft buttons - I think that will lead you in the right direction

its on the old forum (one that got hacked) and we all posted our samples back up ont he forum.

g
 
just re-read Bobs post - oops he's right i thought it read report instead of form

bobs answer will work ignore my ranting - long weekend...
g
 
Okay I seem to have a problem, can you all see what the deal is please?

Code:
Private Sub staffopen_Click()
On Error GoTo Err_staffopen_Click

Dim strInput As String

strInput = InputBox("Please Enter the Password", "Enter Password")

If strInputBox = "staff" Then
   DoCmd.openform "myform", acNormal
Else
   If MsgBox("You entered the wrong password.  Do you wish to try again?", vbQuestion + vbYesNo, "Password Error") = vbYes Then
       GoTo InputBox
End If

End Sub
 
Change it to:
Code:
Private Sub staffopen_Click()
On Error GoTo Err_staffopen_Click
Dim strInput As String
[B]Retry:[/B]
strInput = InputBox("Please Enter the Password", "Enter Password")

If strInputBox = "staff" Then
   DoCmd.openform "myform", acNormal
Else
   If MsgBox("You entered the wrong password.  Do you wish to try again?", vbQuestion + vbYesNo, "Password Error") = vbYes Then
       GoTo [B]Retry[/B]
End If

End Sub
 
sorry 'bout that. Put another End If in right after the GoTo Retry part.
 
Thanks for the help, I have one more thing.

When I enter the password it does not recognize it. Can you take one more look please?

Code:
Private Sub openform_Click()
On Error GoTo Err_openform_Click
Retry:
Dim strInput As String

strInput = InputBox("Please Enter the Password", "Enter Password")

If strInputBox = "ht8staff" Then
   DoCmd.openform "(Dialog) Select Type", acNormal
Else
   If MsgBox("You entered the wrong password.  Do you wish to try again?", vbQuestion + vbYesNo, "Password Error") = vbYes Then
       GoTo Retry
End If
End If

Exit_openform_Click:
    Exit Sub

Err_openform_Click:
    MsgBox Err.Description
    Resume Exit_openform_Click
    
End Sub
 
Block If without End If

The code:
Private Sub staffopen_Click()
On Error GoTo Err_staffopen_Click

Dim strInput As String
strInput = InputBox("Please Enter the Password", "Enter Password")
If strInputBox = "morten" Then
DoCmd.OpenForm "skjema_pris", acNormal
Else
If MsgBox("You entered the wrong password. Do you wish to try again?", vbQuestion + vbYesNo, "Password Error") = vbYes Then
GoTo 0

End If

Exit_staffopen_Click:
Exit Sub

Err_staffopen_Click:
MsgBox Err.Description
Resume Exit_staffopen_Click_Click

End Sub

Then this error acror: Block If witout End If

I get an error in the compilator when i run the code.. any have a sugestin?

M.
 
Last edited:
Hey Bob Larson, are you still available to help here?

RR

Maybe, it all depends on the issue as to whether I have time or not. If it doesn't take much thinking time or response time, then yes. I'm in the middle of a personal project so I am trying to answer as many questions as I can, but I can't delve too deeply.
 
lol..I understand completely and I also appreciate the help you provide.

Basically it looks like everything is in place, but when I enter the password it does not take. I have changed the password and actually redid the button, but still no success.

Here is what I have again:

Code:
Private Sub openform_Click()
On Error GoTo Err_openform_Click
Retry:
Dim strInput As String

strInput = InputBox("Please Enter the Password", "Enter Password")

If strInputBox = "staff" Then
   DoCmd.openform "(Dialog) Select Type", acNormal
Else
   If MsgBox("You entered the wrong password.  Do you wish to try again?", vbQuestion + vbYesNo, "Password Error") = vbYes Then
       GoTo Retry
       
End If
End If

Exit_openform_Click:
    Exit Sub

Err_openform_Click:
    MsgBox Err.Description
    Resume Exit_openform_Click
    
End Sub
 
Put a message box in the part after If strInputBox = "staff Then to see if it is getting there. The part you have:
DoCmd.openform "(Dialog) Select Type", acNormal
doesn't look right. Does your form name actually have (Dialog) in the name? If so, get rid of the special characters in the name. You shouldn't have any special characters in object names (other than maybe an underscore).

This part should be:
DoCmd.openform "YourFormNameHere", acNormal
 
Code:
[b]strInput[/b] = InputBox("Please Enter the Password", "Enter Password")

If [b]strInputBox[/b] = "staff" Then

Your variables are called different things.

If you dont use OPTION EXPLICIT at the head of your modules you should consider it, it helps pick up things like this (assuming that strInputbox isn't a valid variable)
 
Thanks for the help everyone, it works well now. I added to your reputation. :)
 

Users who are viewing this thread

Back
Top Bottom