C
croy
When I open this form from a command button, I get an error:
"You cancelled the previous operation."
The code window indicates that the problem is with my
FilterOn statement in the form's OnOpen code.
Here's the code:
*****
Private Sub Form_Open(Cancel As Integer)
If DLookup("[DistrictId]", "qryDistrictStart") = "4" _
Then
Me.FilterOn = False
Me.AllowAdditions = False
If MsgBox("District is set to 'ALL'. You can _
review, but you won't be able to add or edit records.", _
vbOKCancel + vbDefaultButton2, "District Setting") = vbOK _
Then
Me.AllowAdditions = True
DoCmd.Restore
DoCmd.GoToRecord , , acLast
Else
If CurrentProject.AllForms!frmStart.IsLoaded
Then Forms!frmStart.Visible = True
Cancel = True
End If
Else
Me.AllowAdditions = True
Me.Filter = "FO = " & DLookup("District", _
"tblDistrictStart")
Me.FilterOn = True
DoCmd.Restore
DoCmd.GoToRecord , , acNewRec
End If
End Sub
*****
Any thoughts?
"You cancelled the previous operation."
The code window indicates that the problem is with my
FilterOn statement in the form's OnOpen code.
Here's the code:
*****
Private Sub Form_Open(Cancel As Integer)
If DLookup("[DistrictId]", "qryDistrictStart") = "4" _
Then
Me.FilterOn = False
Me.AllowAdditions = False
If MsgBox("District is set to 'ALL'. You can _
review, but you won't be able to add or edit records.", _
vbOKCancel + vbDefaultButton2, "District Setting") = vbOK _
Then
Me.AllowAdditions = True
DoCmd.Restore
DoCmd.GoToRecord , , acLast
Else
If CurrentProject.AllForms!frmStart.IsLoaded
Then Forms!frmStart.Visible = True
Cancel = True
End If
Else
Me.AllowAdditions = True
Me.Filter = "FO = " & DLookup("District", _
"tblDistrictStart")
Me.FilterOn = True
DoCmd.Restore
DoCmd.GoToRecord , , acNewRec
End If
End Sub
*****
Any thoughts?