Results 1 to 4 of 4
  1. #1
    gafort is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2011
    Location
    Cleveland, Ohio
    Posts
    22

    Is null question


    Sorry I am new. If the form field (email address) is null, how do I print a message box that says "Please enter a valid email address" with an option to enter the address OR click ok and have the cursor back in the "null field" to eliminate the run-time error?

  2. #2
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Here's some pretty standard code for doing that:

    Code:
    Private Sub Form_BeforeUpdate(Cancel As Integer)
    
     If Nz(Me.txtEmailAddress,"") = "" Then
       MsgBox "The Email Address Must Not Be Left Blank!"
       Cancel = True
       txtEmailAddress.SetFocus
       Exit Sub
     End If
     
    End Sub

    Simply replace txtEmailAddress with the actual name of your Control, on the Form, that holds the data.

    Linq ;0)>

  3. #3
    gafort is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2011
    Location
    Cleveland, Ohio
    Posts
    22
    Thank you Linq, worked like a charm. I knew it was simple, just could not find it in the forum.

  4. #4
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Glad we could help!

    Linq ;0)>

Please reply to this thread with any new information or opinions.

Similar Threads

  1. A Null question
    By itm in forum Database Design
    Replies: 3
    Last Post: 08-22-2012, 01:33 PM
  2. If/Then Null based on Null Value of Another Field
    By vbpeterson in forum Queries
    Replies: 11
    Last Post: 06-05-2012, 05:00 PM
  3. Replies: 1
    Last Post: 02-23-2012, 02:27 PM
  4. Finding the Max Date and Null Values if Null
    By SpdRacerX in forum Queries
    Replies: 1
    Last Post: 02-03-2012, 06:29 AM
  5. A NULL Question
    By botts121 in forum Programming
    Replies: 2
    Last Post: 07-09-2009, 07:59 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums