R
Rosemary
I have a simple input form to add records to a table, and it works just fine,
except I keep getting the following error:
The macro or function set to the BeforeUpdate or ValidationRule property for
this field is preventing DOIM BILLING from saving the data in the field.
The key to the table is an autonumber field.
There's a foreign key to another table, which is set in the procedure
(Category_id), since the form is adding subcategories. I've tried different
things to see if they make a difference, but the result is the same. But
even though I see the error message, I still does the insert if I reply Yes
to the prompt. If I reply No it works just fine and does not add the record.
Please help - code is included below:
Private Sub Form_BeforeUpdate(Cancel As Integer)
On Error GoTo Err_Form_BeforeUpdate
Dim strResponse As String
Me.Category_id = Me.hld_Cat_id
If Dirty Then
strResponse = MsgBox("Do you want to save your changes?",
vbYesNoCancel, "Save SubCategory?")
Select Case strResponse
Case vbYes ' User chose Yes.
' Dirty = False (THIS IS COMMENTED OUT)
DoCmd.RunCommand acCmdSaveRecord
Case vbNo
Me.Undo
End Select
End If
Exit_Form_BeforeUpdate:
Exit Sub
Err_Form_BeforeUpdate:
MsgBox Err.Description
Resume Exit_Form_BeforeUpdate
End Sub
except I keep getting the following error:
The macro or function set to the BeforeUpdate or ValidationRule property for
this field is preventing DOIM BILLING from saving the data in the field.
The key to the table is an autonumber field.
There's a foreign key to another table, which is set in the procedure
(Category_id), since the form is adding subcategories. I've tried different
things to see if they make a difference, but the result is the same. But
even though I see the error message, I still does the insert if I reply Yes
to the prompt. If I reply No it works just fine and does not add the record.
Please help - code is included below:
Private Sub Form_BeforeUpdate(Cancel As Integer)
On Error GoTo Err_Form_BeforeUpdate
Dim strResponse As String
Me.Category_id = Me.hld_Cat_id
If Dirty Then
strResponse = MsgBox("Do you want to save your changes?",
vbYesNoCancel, "Save SubCategory?")
Select Case strResponse
Case vbYes ' User chose Yes.
' Dirty = False (THIS IS COMMENTED OUT)
DoCmd.RunCommand acCmdSaveRecord
Case vbNo
Me.Undo
End Select
End If
Exit_Form_BeforeUpdate:
Exit Sub
Err_Form_BeforeUpdate:
MsgBox Err.Description
Resume Exit_Form_BeforeUpdate
End Sub