G
Guest
Hi
I have a 3 way option group whose buttons filter the forms recordset.
In prinicple it works fine but certain sequences of button presses cause an
un-trapable crash with the message:
The macro or function set to the BeforeUpdate or ValidationRule property for
this field is preventing "app name" from saving the data in the field.
The code is show below.
The option group is unbound and its default value is 1.
The fault can always be provoked by pressing either button 2 or 3, followed
by button 1. This seems to arm the form ready for a crash and pressing either
2 or3 causes instant failure.
I think that the fact that option 1 is for all the records where as options
2 and 3 apply a filter is significant but can't seen what i'm doing wrong.
NB The crash occurs instantly before any of the debug break points show any
lines of code being executed.
Thanks for any help.
Private Sub optBusiness_Filter_AfterUpdate()
On Error GoTo Err_optBusiness_Filter_AfterUpdate
If Me.optBusiness_Filter = 1 Then
DoCmd.ShowAllRecords
Me.txtGet_BU_Id.Requery
End If
If Me.optBusiness_Filter = 2 Then
DoCmd.ApplyFilter , "BU_Accepted_Date Is not Null and BU_Date_Sold
is null"
Me.Requery
Me.txtGet_BU_Id.Requery
End If
If Me.optBusiness_Filter = 3 Then
DoCmd.ApplyFilter , "BU_Accepted_Date is not null and BU_Date_Sold
Is Not Null"
Me.txtGet_BU_Id.Requery
End If
If Me.RecordsetClone.RecordCount > 0 Then
DoCmd.GoToControl "txtBU_Name"
Me.txtGet_BU_Id.Requery
End If
If Me.RecordsetClone.RecordCount = 0 Then
MsgBox "There are no records."
DoCmd.ShowAllRecords
Me.optBusiness_Filter = 1
Me.txtGet_BU_Id.Requery
DoCmd.GoToControl "txtBU_Name"
End If
Exit_optBusiness_Filter_AfterUpdate:
Exit Sub
Err_optBusiness_Filter_AfterUpdate:
MsgBox Err.Description
Resume Exit_optBusiness_Filter_AfterUpdate
End Sub
I have a 3 way option group whose buttons filter the forms recordset.
In prinicple it works fine but certain sequences of button presses cause an
un-trapable crash with the message:
The macro or function set to the BeforeUpdate or ValidationRule property for
this field is preventing "app name" from saving the data in the field.
The code is show below.
The option group is unbound and its default value is 1.
The fault can always be provoked by pressing either button 2 or 3, followed
by button 1. This seems to arm the form ready for a crash and pressing either
2 or3 causes instant failure.
I think that the fact that option 1 is for all the records where as options
2 and 3 apply a filter is significant but can't seen what i'm doing wrong.
NB The crash occurs instantly before any of the debug break points show any
lines of code being executed.
Thanks for any help.
Private Sub optBusiness_Filter_AfterUpdate()
On Error GoTo Err_optBusiness_Filter_AfterUpdate
If Me.optBusiness_Filter = 1 Then
DoCmd.ShowAllRecords
Me.txtGet_BU_Id.Requery
End If
If Me.optBusiness_Filter = 2 Then
DoCmd.ApplyFilter , "BU_Accepted_Date Is not Null and BU_Date_Sold
is null"
Me.Requery
Me.txtGet_BU_Id.Requery
End If
If Me.optBusiness_Filter = 3 Then
DoCmd.ApplyFilter , "BU_Accepted_Date is not null and BU_Date_Sold
Is Not Null"
Me.txtGet_BU_Id.Requery
End If
If Me.RecordsetClone.RecordCount > 0 Then
DoCmd.GoToControl "txtBU_Name"
Me.txtGet_BU_Id.Requery
End If
If Me.RecordsetClone.RecordCount = 0 Then
MsgBox "There are no records."
DoCmd.ShowAllRecords
Me.optBusiness_Filter = 1
Me.txtGet_BU_Id.Requery
DoCmd.GoToControl "txtBU_Name"
End If
Exit_optBusiness_Filter_AfterUpdate:
Exit Sub
Err_optBusiness_Filter_AfterUpdate:
MsgBox Err.Description
Resume Exit_optBusiness_Filter_AfterUpdate
End Sub