Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2012
    Posts
    38

    Unanswered: How can I get a message box to display if a user clicks a button on a form and left a

    Both the command button and the field are on the same form (Form1). I want the user to fill in the blank, so if they leave it blank I want the command button to prompt a message box telling them to fill in the blank (rather than starting the code that the command button is actually for).

    Here's the code I have behind the command button right now:

    Code:
    Private Sub cmd_PullQtOrd_Click()
    If Forms!Form1.Text83.Value = Null Then
    MsgBox.Show "Please enter your e-mail into into the Form1 textbox labeled 'User E-Mail'"
    Else
    ChkForNullEmails
    End If
    End Sub

  2. #2
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    Null propagates. If used in an arithmetic or logic operation, or used in a comparison, the result will always be Null, while If expects the result of the evaluation expression be either True (-1) or False (0).
    Change:
    Code:
    If Forms!Form1.Text83.Value = Null Then
    To:
    Code:
    If IsNull(Me.Text83.Value) = True Then
    Or for short:
    Code:
    If IsNull(Me.Text83.Value) Then
    Have a nice day!

  3. #3
    Join Date
    Jun 2012
    Posts
    38
    Thank you. I posted my issue on another forum simultaneously and someone suggested this:

    Code:
    If Len(Forms!Form1.Text83 & vbNullString) = 0 Then 
      MsgBox "You need to fill out the address" 
    Else 
      'your code here to send the email 
    End If
    This solved the issue for me.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •