C
Chuck
I have a situation where I must verify that both of two related controls have
been entered or neither has been entered. The following code does just what
I want except that Access seems to be ignoring the Cancel value:
Function CrossCheckKeys(Cancel As Integer)
Dim CurrForm As Form: Set CurrForm = Screen.ActiveForm
With CurrForm
If (IsNull(.Controls("comSinkKey")) And Not
IsNull(.Controls("comSrceKey"))) _
Or (IsNull(.Controls("comSrceKey")) And Not
IsNull(.Controls("comSinkKey"))) Then
If IsNull(.Controls("comSinkKey")) Then
MsgRtn "DYN003", "Sink", "Source"
Else
MsgRtn "DYN003", "Source", "Sink"
End If 'IsNull(.Controls("SinkKey"))
Cancel = True
Else
BeforeFormUpdate
End If '(.Controls("SinkForm") = "" And .Controls("SrceForm") <> "") _
....
End With 'CurrForm
End Function
This code is logically identical to other functions I've used with Control
BeforeUpdate events and it worked just fine there. With the Form
BeforeUpdate event, Access ignores the fact that Cancel is True and saves the
bad record without allowing the user to correct it in response to the error
message.
I tried invoking this function from an [Event Procedure] and got the same
bad results.
Any ideas? Thanks in advance for any assistance.
been entered or neither has been entered. The following code does just what
I want except that Access seems to be ignoring the Cancel value:
Function CrossCheckKeys(Cancel As Integer)
Dim CurrForm As Form: Set CurrForm = Screen.ActiveForm
With CurrForm
If (IsNull(.Controls("comSinkKey")) And Not
IsNull(.Controls("comSrceKey"))) _
Or (IsNull(.Controls("comSrceKey")) And Not
IsNull(.Controls("comSinkKey"))) Then
If IsNull(.Controls("comSinkKey")) Then
MsgRtn "DYN003", "Sink", "Source"
Else
MsgRtn "DYN003", "Source", "Sink"
End If 'IsNull(.Controls("SinkKey"))
Cancel = True
Else
BeforeFormUpdate
End If '(.Controls("SinkForm") = "" And .Controls("SrceForm") <> "") _
....
End With 'CurrForm
End Function
This code is logically identical to other functions I've used with Control
BeforeUpdate events and it worked just fine there. With the Form
BeforeUpdate event, Access ignores the fact that Cancel is True and saves the
bad record without allowing the user to correct it in response to the error
message.
I tried invoking this function from an [Event Procedure] and got the same
bad results.
Any ideas? Thanks in advance for any assistance.