I am using Microsoft's Password routine for "causual" protection of forms...
After splitting the database to a frontend and backend I get a 3219 "Invalid Operation" error when entering a Password - the form
that is protected loads regardless.
Snip of the code
frmPASSWORD...
--------------------------
----------
----------
----------
----------
----------
----------
----------
----------
----------
---
Option Compare Database
Private Sub CheckPassword_Click()
On Error GoTo Err_CheckPassword_Click
If IsNull(Forms!frmPassword!T
ext0.Value
) Then
MsgBox "You cannot enter a blank Password. Try again."
Me!Text0.SetFocus
Else
MyPassword = Me!Text0.Value
DoCmd.Close acForm, "frmPassword"
End If
Exit_CheckPassword_Click:
Exit Sub
Err_CheckPassword_Click:
MsgBox Err.Description
Resume Exit_CheckPassword_Click
End Sub
Private Sub Command3_Click()
On Error GoTo Err_Command3_Click
DoCmd.Close
Exit_Command3_Click:
Exit Sub
Err_Command3_Click:
MsgBox Err.Description
Resume Exit_Command3_Click
End Sub
Private Sub Text0_AfterUpdate()
If IsNull(Forms!frmPassword!T
ext0.Value
) Then
MsgBox "You cannot enter a blank Password. Try again."
Me!Text0.SetFocus
Else
MyPassword = Me!Text0.Value
DoCmd.Close acForm, "frmPassword"
End If
Exit_CheckPassword_Click:
Exit Sub
End Sub
--------------------------
----------
----------
----------
----------
----------
----------
-
Code for the OnOpen of the protected Form - where the error occurs:
--------------------------
----------
----------
----------
----------
----------
----------
----------
----------
---------
Private Sub Form_Open(Cancel As Integer)
strRecordSource = Me.RecordSource
TTManual.SetFocus
Dim Hold As Variant
Dim tmpKey As Long
Dim I As Integer
Dim rs As DAO.Recordset
Dim db As DAO.Database
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
Set rs = db.OpenRecordset("tblPassw
ord", dbOpenTable)
rs.Index = "PrimaryKey"
rs.Seek "=", Me.Name
If rs.NoMatch Then
MsgBox "Sorry cannot find password information. Try Again"
Cancel = -1
Else
' Test to see if the key generated matches the key in
' the table; if there is not a match, stop the form
' from opening.
If Not (rs![KeyCode] = KeyCode(CStr(Hold))) Then
MsgBox "Sorry you entered the wrong password." & _
"Try again.", vbOKOnly, "Incorrect Password"
Cancel = -1
End If
End If
rs.Close
db.Close
Exit Sub
Error_Handler:
MsgBox Err.Description, vbOKOnly, "Error #" & Err.Number
Exit Sub
End Sub
--------------------------
----------
----------
----------
----------
----------
----------
-------
Any ideas where to begin?