> Jeff,
> yes, I would like to close the form without a password error message and I
> have not made any changes to the on open procedure. thanks for your help.
Okie Dokie.
Follow these steps:
1. Make a couple backup copies of your database first
2. Open the frmPassword and change the Exit command button
Click event code to this:
Private Sub cmdExit_Click()
MyPassword = "ExitButton"
DoCmd.Close acForm, "frmPassword"
End Sub
3. Save and close that form
4. Open one of the forms that you are password protecting.
Go to the code window behind this form and look for the Open
event code. It should be exactly like the KB article code.
Look for this area of the code:
On Error GoTo Error_Handler
' Prompt the user for the Password.
DoCmd.OpenForm "frmPassword", acNormal, , , , acDialog
Hold = MyPassword
' Open the table that contains the password.
Set db = CurrentDb
....yadda....yadda....
In between those two areas we will add a few more lines of code.
It should now look like this:
On Error GoTo Error_Handler
' Prompt the user for the Password.
DoCmd.OpenForm "frmPassword", acNormal, , , , acDialog
Hold = MyPassword
' User pressed exit button so skip everything else
If Hold = "ExitButton" Then
Cancel = True
Exit Sub
End If
' Open the table that contains the password.
Set db = CurrentDb
....yadda....yadda....
What this will do is tell Access to cancel opening the protected form,
but not display anything since the rest of the code procedure is just
skipped.
You will need to enter the same code in the same spot for any other
forms or reports you are password protecting. Also, do NOT use
ExitButton as a password for any of the forms and reports.
Everything works fine in my tests.
Hope that helps,

Signature
Jeff Conrad
Access Junkie
Bend, Oregon
Kyle Friesen - 25 Feb 2005 20:59 GMT
great! thanks. one more quick one for you, Jeff.
Now I am getting a VB Error "The OpenForm action was canceled".
The form being the password protected object. Any ideas on how to elimate
that error message too?
Kyle Friesen - 25 Feb 2005 21:13 GMT
Jeff, I changed the command button's on click from an event procedure to a
macro and turned the warnings off.
everything works fine now, thanks for your help.
Kyle
Jeff Conrad - 25 Feb 2005 21:43 GMT
> Jeff, I changed the command button's on click from an event procedure to a
> macro and turned the warnings off.
>
> everything works fine now, thanks for your help.
While the macro will work Kyle, I would not recommend it.
The macro could by chance encounter other error messages
which would cause Access to cough up a "Halt" hair ball.
I would suggest just trapping and ignoring the error as I
outlined in my other post.

Signature
Jeff Conrad
Access Junkie
Bend, Oregon
Jeff Conrad - 25 Feb 2005 21:21 GMT
> great! thanks. one more quick one for you, Jeff.
>
> Now I am getting a VB Error "The OpenForm action was canceled".
>
> The form being the password protected object. Any ideas on how to elimate
> that error message too?
Yep, easy to fix.
Error 2501 is the one you are encountering and it is the standard Access
message for this type of thing. The error is actually occurring on the main
form, not the protected one or frmPassword. You said you had a main
form that you users clicked to open the protected form. That main form
is the one you need to open in Design View and go to the code for
the click event of the button that opens the protected form.
We need to add some error handling to this click event. Most likely there
probably already is some error handling code. You just need to ignore
Error 2501. You will have to modify this example code for your situation:
Private Sub cmdOpenForm_Click()
On Error GoTo ErrorPoint
DoCmd.OpenForm "ProtectedFormNameHere"
ExitPoint:
Exit Sub
ErrorPoint:
If err.Number <> 2501 Then
' Unexpected Error
MsgBox "The following error has occurred:" _
& vbNewLine & "Error Number: " & err.Number _
& vbNewLine & "Error Description: " & err.Description _
, vbExclamation, "Unexpected Error"
End If
Resume ExitPoint
End Sub
If you still have problems adapting this into your code, just post
all the code behind the click event for that main form button and
I will make the modifications for you.

Signature
Jeff Conrad
Access Junkie
Bend, Oregon