On Error?

T588

Registered User.
Local time
Yesterday, 21:47
Joined
Feb 3, 2003
Messages
65
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
***************************************
 

Attachments

Fixed- needed to make both order# and product a primary key in order details table. The On Error event is triggered by an error on the form - I didn't know this - I needed to create an error (that's a new one!) before the event would respond.

Vince
 

Users who are viewing this thread

Back
Top Bottom