IsNull for multiple fields

guestbb

Registered User.
Local time
Yesterday, 17:17
Joined
Jul 14, 2015
Messages
44
I want using If and IsNull to make user insert data in 5 textboxes before he can access rest of the data.

I used this code, but when every just one of the fields is filled it open the rest of data.
How to write the If and IsNull function so that it requires all of this textoboxes filled first?

Code:
If IsNull (me.textbox1 & me.textbox2 & me.textbox3 & me.textbox4 & me.textbox5) Then
MsgBox ("Insert all data first")
Exit Sub
End If

Rest of the code.
 
This should work:

If IsNull(textbox1.value) or IsNull(textbox2.value) or IsNull(textbox3.value) or IsNull(textbox4.value) or IsNull(textbox5.value) Then

Or this too:
If IsNull(textbox1.value + textbox2.value + textbox3.value + textbox4.value + textbox5.value) Then

The first way works because it checks if each value is null
The second way works because if you try adding strings together using the + opperator and there's a null value in any of the vars, the output is NULL.
 
I forgot to add, if you use the & operator instead of the + operator, it ignores the null values. This is why your code didn't work.
 

Users who are viewing this thread

Back
Top Bottom