Results 1 to 6 of 6
  1. #1
    rockape is offline Novice
    Windows XP Access 97
    Join Date
    Sep 2009
    Posts
    10

    Unhappy Is null problem


    Hi,

    a slight problem:

    I have included this event procedure

    Private Sub person_BeforeUpdate(Cancel As Integer)
    If Me![person] Is Null Then
    MsgBox "Please enter details"
    Cancel = True
    End If
    End Sub

    Basically I'm to ensure that a name is entered in the field. It won't work. Any clues someone?

    Cheers

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    I thought I had answered this somewhere.
    Code:
    Private Sub person_BeforeUpdate(Cancel As Integer)
    If Len(Me.person & "") = 0 Then
       MsgBox "Please enter details"
       Cancel = True
    End If
    End Sub

  3. #3
    rockape is offline Novice
    Windows XP Access 97
    Join Date
    Sep 2009
    Posts
    10
    Quote Originally Posted by RuralGuy View Post
    I thought I had answered this somewhere.
    Code:
    Private Sub person_BeforeUpdate(Cancel As Integer)
    If Len(Me.person & "") = 0 Then
       MsgBox "Please enter details"
       Cancel = True
    End If
    End Sub
    hi RG,

    no luck. On enter the message will not appear and cursor moves along to next input box.

    Not my day today!

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Move the code to the OnExit event instead. You do not get a BeforeUpdate event unless the control has been changed by the user in some way.

  5. #5
    rockape is offline Novice
    Windows XP Access 97
    Join Date
    Sep 2009
    Posts
    10
    Thanks RG,

    Your input has been invaluable and set me on the right track.

    Advised to Code put in form instead of control:

    Private Sub Form_BeforeUpdate(Cancel As Integer)
    If Nz(Me.Person, "") = "" Then
    MsgBox "Please enter missing details"
    Cancel = True
    End If

    End Sub

    Cheerio

  6. #6
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    That is a good solution too.

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

Similar Threads

  1. A NULL Question
    By botts121 in forum Programming
    Replies: 2
    Last Post: 07-09-2009, 07:59 PM
  2. Replacing Null with 0
    By gilagain1 in forum Queries
    Replies: 5
    Last Post: 04-23-2009, 01:47 PM
  3. Fill in Null values
    By Petefured in forum Queries
    Replies: 1
    Last Post: 10-06-2008, 12:54 PM
  4. HELP with NULL DateTime VALUES
    By lfolger in forum Programming
    Replies: 3
    Last Post: 03-28-2008, 02:33 PM
  5. Null vs New Record
    By jversiz in forum Access
    Replies: 2
    Last Post: 02-20-2008, 12:02 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