Logical Or

cynapattery

Registered User.
Local time
Yesterday, 16:51
Joined
Jul 9, 2013
Messages
28
Hi,

I am trying to check whether either one of the following text fields are filled and only then to proceed.
I used an If ElseIf loop where first criteria(name) should be filled. and minimum one textbox from rest of it.

Code:
If IsNull(Me.FirstName) Then
MsgBox ("FirstName Missing!")
ElseIf IsNull(Me.Website.Value) Or IsNull(Me.Email1.Value) Or IsNull(Me.online_form.Value) Then
 
MsgBox ("Data Missing!")
Else

But when I run it, it checks like an AND function. It checks whether first name is missing and then only if all the fields(website, email, onlineform) are filled I can proceed.
Thanks & Awaiting a solution.
 
are you sure your data has nulls and not zero length strings?
 
I think that you should use AND because you want the message "data missing" if all the fields are empty. This is the way i see it. Am i wrong?
 
Try using the Nz method, I have never had any problem with it.

If Nz(Me.FirstName) = "" Then
MsgBox ("FirstName Missing!")
ElseIf (Nz(Me.WebSite) & Nz(Me.Email1.Value) & Nz(Me.online_form.Value) = "") Then
MsgBox ("Data Missing!")
Else
 
Hi ,
thanks for the replies. I tried Nz and then I got a type missmatch error.

I want to check if either of the following fields (website, email, online form) then perform the task. All the fields must not be filled.

CJ London, i am not clear with your question. I have a 4 text field. If someone enter any data in any of the text field and click the save button, first it should check whether name is smpty. If not it should check whether there is either email address or online form or website.

Thanks again.
 
Also for me the code appears to do what is intended to do:
If one of this field is null then the message box should pop up.
So use the AND instead OR (Catalin say you the same in post #3)
 
Hi Thanks a lot.
It worked as I changed as both of you suggested.
actually I was thinking as Logical OR. (1+0+1 = 1) but that is not how considered here I think. :)
Thanks again.
 
A null is not a zero length string - a better test is Nz(Me.FirstName)=""

You do not need to use .value so it looks to me like the solution proposed by highandwild should work. I don't see how you are getting a type mismatch error by using nz
 
And is the logic for day to day:

IF I'm tired OR I'm busy THEN I can't go to a beer.
IF I'm NOT tired AND I'm NOT busy THEN I'll go to a beer.
 

Users who are viewing this thread

Back
Top Bottom