If is Null Problem

B

Bob V

Im trying to get my 2 check boxes to show if there is any Value in my text
box tbEmail
This is not working............Thanks Bob
Private Sub Form_Current()

If IsNull(Me.Email) Then
Me.ckbEmailAlert = 0 Or Me.ckbBachInvoice = 0
Else
Me.ckbEmailAlert = -1 Or Me.ckbBachInvoice = 1
End If
End Sub
 
R

Roger Converse

Hello,

You need an "= true" before yourthen.

IsNull() is a function which returns a value of true or false.

Private Sub Form_Current()

If IsNull(Me.Email) = true Then
Me.ckbEmailAlert = 0 Or Me.ckbBachInvoice = 0
Else
Me.ckbEmailAlert = -1 Or Me.ckbBachInvoice = 1
End If
End Sub

HTH,
Roger
 
J

John W. Vinson

Im trying to get my 2 check boxes to show if there is any Value in my text
box tbEmail
This is not working............Thanks Bob
Private Sub Form_Current()

If IsNull(Me.Email) Then
Me.ckbEmailAlert = 0 Or Me.ckbBachInvoice = 0
Else
Me.ckbEmailAlert = -1 Or Me.ckbBachInvoice = 1
End If
End Sub
[/QUOTE]

OR doesn't work like you think. The OR operator combines two statements,
returning TRUE if either or both are TRUE, FALSE otherwise.

It's not at all clear what you want to happen; are you trying to set the
values of two checkbox controls, to unchecked if Email is null, checked if it
is not? If so

If IsNull(Me.Email) Then
Me.ckbEmailAlert = False
Me.ckbBachInvoice = False
Else
Me.ckbEmailAlert = True
Me.ckbBachInvoice = True
End If

or more simply: just two lines -

Me!ckbEmailAlert = Not IsNull(Me!Email)
Me!ckbBachInvoice = Not IsNull(Me!Email)

John W. Vinson [MVP]
 
J

John W. Vinson

You need an "= true" before yourthen.

Well, actually you don't - the IF will branch based on whether the expression
before THEN is True or False. You don't need the extra step.

John W. Vinson [MVP]
 
Top