C
Chuck
I have a situation where two fields (both Combo Boxes in this case) are
optional if neither is used and required if either is used; i.e., if either
one is used they must both be used. The Form BeforeUpdate property is
'=CrossCheckKeys(0)'. The CrossCheckKeys function is:
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("SinkKey")) 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
The CrossCheckKeys code does exactly what I want when one key has a value
and the other is null except that Cancel seems to be ignored. It is being
set to -1 when appropriate but the bad record is still written to the
database.
I tried putting an [Event Procedure] between the Before Update property and
the CrossCheckKeys function but the result was the same.
Thank you in advance for any suggestions.
optional if neither is used and required if either is used; i.e., if either
one is used they must both be used. The Form BeforeUpdate property is
'=CrossCheckKeys(0)'. The CrossCheckKeys function is:
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("SinkKey")) 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
The CrossCheckKeys code does exactly what I want when one key has a value
and the other is null except that Cancel seems to be ignored. It is being
set to -1 when appropriate but the bad record is still written to the
database.
I tried putting an [Event Procedure] between the Before Update property and
the CrossCheckKeys function but the result was the same.
Thank you in advance for any suggestions.