D
Dave Hawks
I have an application that uses two forms.
The first form displays and allows users to enter their name to reserve a
time.
To prevent unauthorised deletions the second form asks the user for their
password before confirming the deletion.
The first form frm Table1 uses the following code on the before update
property.
Private Sub Player3_BeforeUpdate(Cancel As Integer)
Dim Response As String
If IsNull(Player1.OldValue) Then
Player1.Locked = False
Else
If Not IsNull(Player3.OldValue) Then
Dim MyForm As String
MyForm = "frmAuthenticate"
DoCmd.OpenForm MyForm
Forms![frmAuthenticate]![txtUserId] = Forms![Table1]![Player3]
Cancel = True
Player3.Undo
Else
End If
End If
End Sub
The second form frmAuthenticate uses the following code to check the
password on the click property of button cmdAuthenticate.
Private Sub cmdAuthenticate_Click()
On Error GoTo Err_cmdAuthenticate_Click
Dim oRS As ADODB.Recordset
strSQL = "SELECT * FROM [tblUsers] WHERE USERID = '" & Me.txtUserId.Value &
"' AND PWORD = '" & Me.txtPword.Value & "'"
_
Set oRS = New ADODB.Recordset
oRS.Open strSQL, CurrentProject.Connection, adOpenForwardOnly,
adLockOptimistic
'Ensure there is a match...
If oRS.EOF And oRS.BOF Then 'if this is true, there is no match...
'Insert Code to tell the User they do not have permission...
'Like a message box with no choices...
Response = MsgBox("Wrong Password", vbOKOnly)
'Clean up and close recordset...
oRS.Close
Set oRS = Nothing
DoCmd.Close acForm, "frmAuthenticate", acSaveNo
Exit Sub
Else
'Insert Code to allow the user to delete...
'Like setting the delete property of the form to YES...
I tried the following
[Table1]![Player3].Locked = False
DoCmd.Close acForm, "frmAuthenticate", acSaveNo
oRS.Close
Set oRS = Nothing
End If
Exit_cmdAuthenticate_Click:
Exit Sub
Err_cmdAuthenticate_Click:
MsgBox Err.Description
Resume Exit_cmdAuthenticate_Click
End Sub
My problem is getting the instruction to allow the deletion to work in frm
Table1.
How do I pass the command from frm Authentiacte to delete the record Player3
in frmTable1.
Thanks for your help
--
The first form displays and allows users to enter their name to reserve a
time.
To prevent unauthorised deletions the second form asks the user for their
password before confirming the deletion.
The first form frm Table1 uses the following code on the before update
property.
Private Sub Player3_BeforeUpdate(Cancel As Integer)
Dim Response As String
If IsNull(Player1.OldValue) Then
Player1.Locked = False
Else
If Not IsNull(Player3.OldValue) Then
Dim MyForm As String
MyForm = "frmAuthenticate"
DoCmd.OpenForm MyForm
Forms![frmAuthenticate]![txtUserId] = Forms![Table1]![Player3]
Cancel = True
Player3.Undo
Else
End If
End If
End Sub
The second form frmAuthenticate uses the following code to check the
password on the click property of button cmdAuthenticate.
Private Sub cmdAuthenticate_Click()
On Error GoTo Err_cmdAuthenticate_Click
Dim oRS As ADODB.Recordset
strSQL = "SELECT * FROM [tblUsers] WHERE USERID = '" & Me.txtUserId.Value &
"' AND PWORD = '" & Me.txtPword.Value & "'"
_
Set oRS = New ADODB.Recordset
oRS.Open strSQL, CurrentProject.Connection, adOpenForwardOnly,
adLockOptimistic
'Ensure there is a match...
If oRS.EOF And oRS.BOF Then 'if this is true, there is no match...
'Insert Code to tell the User they do not have permission...
'Like a message box with no choices...
Response = MsgBox("Wrong Password", vbOKOnly)
'Clean up and close recordset...
oRS.Close
Set oRS = Nothing
DoCmd.Close acForm, "frmAuthenticate", acSaveNo
Exit Sub
Else
'Insert Code to allow the user to delete...
'Like setting the delete property of the form to YES...
I tried the following
[Table1]![Player3].Locked = False
DoCmd.Close acForm, "frmAuthenticate", acSaveNo
oRS.Close
Set oRS = Nothing
End If
Exit_cmdAuthenticate_Click:
Exit Sub
Err_cmdAuthenticate_Click:
MsgBox Err.Description
Resume Exit_cmdAuthenticate_Click
End Sub
My problem is getting the instruction to allow the deletion to work in frm
Table1.
How do I pass the command from frm Authentiacte to delete the record Player3
in frmTable1.
Thanks for your help
--