If Statement

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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 Len(Me.TxtAAAAA.Value & "") = 0 And _
Len(Me.TXTBBB.Value & "") = 0 Then
MsgBox "There are no values!"
End If
 
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
 
Back
Top