I stole the following macro from Microsofts’ “NorthWind” Database - adapted it slightly for my form. I cannot get it to function? Similar to how it functions in NorthWind, If a Branch ID is not selected prior to a product on the subform - I would like it to display an error message and upon confirmation to delete any entries in the subform and set the focus on BranchID (parent form) A stripped down working version of my form is attached – I would be extremely grateful if someone would look at this and diagnose my error.
Thank you,
Vince
*************************************************
Private Sub Form_Error(DataErr As Integer, Response As Integer)
' Errors can occur here if the user has not already selected a Branch Location for
' this order on the main form. If there is an error and Orders!Branch # is Null
' inform the user and cancel the entry made in the subform.
If DataErr > 0 Then
If IsNull(Me.Parent!BranchNumber) Then
MsgBox "Select a Branch Location before entering order details info."
RunCommand acCmdUndo
Me.Parent!BranchNumber.SetFocus
Response = acDataErrContinue
Else
Response = acDataErrDisplay
End If
End If
End Sub
***************************************
Thank you,
Vince
*************************************************
Private Sub Form_Error(DataErr As Integer, Response As Integer)
' Errors can occur here if the user has not already selected a Branch Location for
' this order on the main form. If there is an error and Orders!Branch # is Null
' inform the user and cancel the entry made in the subform.
If DataErr > 0 Then
If IsNull(Me.Parent!BranchNumber) Then
MsgBox "Select a Branch Location before entering order details info."
RunCommand acCmdUndo
Me.Parent!BranchNumber.SetFocus
Response = acDataErrContinue
Else
Response = acDataErrDisplay
End If
End If
End Sub
***************************************