Evaluate Null values

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rwalle
    New Member
    • Jan 2010
    • 47

    Evaluate Null values

    HI
    I have some problems to evaluate null values,[EmpName] is a string form field that display employee names if an employee is in the table where form is based it works fine for employees that are in the table but when a null val is displayed on this field the If statement doesn't work am I missing something or is there a diferent way to evaluate empty string field values ??

    Tks for your help
    Raymundo Walle
    Code:
    If Me.EmpName = "" Then
    MsgBox "Usted no esta registrado en este sistema", 16, "Falla de Autentificacion"
    DoCmd.Close
    Else
    DoCmd.OpenForm "Principal", acNormal, , , acFormEdit, acWindowNormal, ""
    
    End If
    Debug.Print Me.EmpName
    End Sub
  • Mihail
    Contributor
    • Apr 2011
    • 759

    #2
    Code:
    If IsNull(Me.EmpName) Then ...
    .
    Last edited by NeoPa; Jun 26 '11, 07:00 PM. Reason: Don't forget the CODE tags Mihail. Thay're mandatory.

    Comment

    • Stewart Ross
      Recognized Expert Moderator Specialist
      • Feb 2008
      • 2545

      #3
      Even simpler is just

      Code:
      If Nz(Me.EmpName) = "" Then
      In this type of usage Nz returns an empty string if faced with a null - which is exactly what you want.

      There is an alternative use of Nz which is not required in this case:

      Code:
      someval = Nz(anothervalue, returnvalue)
      The short form listed above is exactly the same in its effect as the following full usage of Nz:

      Code:
      If Nz(Me.EmpName, "") = "" Then
      -Stewart

      Comment

      • rwalle
        New Member
        • Jan 2010
        • 47

        #4
        Mihail, Stewart:
        thanks for your response the form is doing what it's intended to

        Thanks

        Raymundo Walle

        Comment

        Working...