If Statement

N

NNlogistics

I am a fairly new user. I cant find an example of using an if statement to
check if two fields both contain data, then display a message. In this case
one field is a date and the other is text. So I thought it would look like
this
If TxtAAAAA and TXTBBB are not Null then msgbox.
 
K

Ken Snell [MVP]

If Len(Me.TxtAAAAA.Value & "") = 0 And _
Len(Me.TXTBBB.Value & "") = 0 Then
MsgBox "There are no values!"
End If
 
D

Dirk Goldgar

NNlogistics said:
I am a fairly new user. I cant find an example of using an if
statement to check if two fields both contain data, then display a
message. In this case one field is a date and the other is text. So
I thought it would look like this
If TxtAAAAA and TXTBBB are not Null then msgbox.

If you don't permit zero-length strings in your text fields, then this
would do it:

If Not (IsNull(Me!txtAAAAA) Or IsNull(Me!txtBBBB)) Then
MsgBox "Both text boxes contain data!"
End If

I don't like negative logic much, though, because it takes too much
brainpower to sort it out. I'd normally prefer this:

If IsNull(Me!txtAAAAA) Or IsNull(Me!txtBBBB) Then
' one or both is Null
Else
MsgBox "Both text boxes contain data!"
End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top