something wrong with and/or logic in if...then statement

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

Guest

I have the following as a validation subroutine for a form:

Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me!Box1 = 0 And _
Me!Box2 = 0 And _
Me!Box3 = 0 And _
 
Rather than
(IsNull(Me!OtherTextfield1) = False Or _
IsEmpty(Me!OtherTextfield1) = False)
Try
Len(Trim(Nz(Me!OtherTextfield1,"")) = 0

(Likewise for OtherTextfield2)

If the control is Null, Nz converts it to an empty string.
If the control has a space, Trim converts it to an empty string.
If the resulting Length is now 0, it can be considered empty.

(Depending on how you "clear" a textbox, it might still fail both the IsNull
and IsEmpty tests)

Something like the following might work too:
If Me!Box1 + Me!Box2 + Me!Box3 + Len(Trim(Nz(Me!OtherTextfield1,"")) +
Len(Trim(Nz(Me!OtherTextfield2,"")) = 0 Then

HTH,
 
George,
thanks so much - that works great!!! i like the second option, but just
stuck with the series of "and"'s, since it was all typed in.

anyway, your help is much appreciated!
janaki
 
Back
Top