| re: Or in the Of clause
I'm not sure why it's not working, but I sure know how to make it more clear,
easier to debug and maintain...
Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me.Parent!customerid = 123 Then Exit Sub
If IsNull(Me.Quantity) Or Me.Cartons<>False Then
MsgBox "You must enter either quantity or cartons", _
vbCritical+vbOkOnly
Cancel = True
End If
End Sub
On 3 Oct 2005 23:41:05 -0700, "samotek" <samotek@abv.bg> wrote:
[color=blue]
>The Or condition in my If clause is not working and seems to give no
>results.My target is to achieve a condition by which either quantity or
>cartons is null.
>That is to say if quantity is Null but cartons is not, the code should
>allow the process and not discontinue.
>But this doesnt happen. The code i have written looks only for
>quantity, and if quantity is null, the message appears, regardless that
>i have entered cartons.
>Obiisouly my Or in the If condition is not right. Any help ?
>
>Private Sub Form_BeforeUpdate(Cancel As Integer)
>If IsNull(Me.Quantity) And Me.Parent!customerid <> 123 Or (Me.cartons)
>And Me.Parent!customerid <> 123 Then
>MsgBox "You must enter either quantity or cartons", vbCritical
>Cancel = True
>DoCmd.GoToControl "productid"
>DoCmd.Beep
>DoCmd.Beep
>ClearForm
>Exit Sub
>End If
>End Sub[/color] |