Bound Controls

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

Guest

I have a control (a text box) bound to an expression. Sometimes the text
box will have a record in it and sometimes it will not. The problem is I am
trying to use the text or value in text box for criteria in an If Then
statement (see below). It is like not "reading" what is in the text box
rather it is null or not null. Any suggestions?


txtBackupEmail.SetFocus

If txtBackupEmail.Text = Not Null Then
DoCmd.SendObject acSendReport, stDocName, acFormatHTML, _
Forms.Telecenter.txtPrimaryEmail, Forms.Telecenter.txtBackupEmail, , _
Forms.Telecenter.txtTelAdjNumber & " " & Forms.Telecenter.txtTelAdjName
& _
" Non-Mon File", , True
Else
End If

txtBackupEmail.SetFocus

If txtBackupEmail.Text = Null Then
DoCmd.SendObject acSendReport, stDocName, acFormatHTML, _
Forms.Telecenter.txtPrimaryEmail, , , _
Forms.Telecenter.txtTelAdjNumber & " " & Forms.Telecenter.txtTelAdjName
& _
Non-Mon File", , True
Else
End If
 
You can't check for Null like that.

If IsNull(txtBackupEmail.Text) = False Then

or

If IsNull(txtBackupEmail.Text) = True Then

Alternatively, you could use

DoCmd.SendObject acSendReport, stDocName, acFormatHTML, _
Forms.Telecenter.txtPrimaryEmail, _
Nz(Forms.Telecenter.txtBackupEmail, ""), , _
Forms.Telecenter.txtTelAdjNumber & " " & Forms.Telecenter.txtTelAdjName & _
" Non-Mon File", , True

and not bother with your (redundant) checks for Not Null or Null.
 
Back
Top