Solved

MS Access How can I check for a text value in a null value field?

Posted on 2013-01-29
9
410 Views
Last Modified: 2013-01-29
This code works fine until I added the piece in bold:

Private Sub Project_Name_AfterUpdate()


      If "" & Me.ProjectName <> "" And IsDate(Me.AendDate) = False And Me.Status <> "Cancelled" Then
        Me.Status = "Working"
    End If
End Sub

This statement doesn't work due to a null value in the Status Field.
(Only works with existing text in the Status field)

How can I check for text "Cancelled" in a null value field?
0
Comment
Question by:DJPr0
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
  • +1
9 Comments
 
LVL 65

Assisted Solution

by:Jim Horn
Jim Horn earned 200 total points
ID: 38831296
>How can I check for text "Cancelled" in a null value field?
Couple of ways..
IsNull(Me.Status) will return True if Null, False if not null
Nz(Me.Status, "foo") will return the Me.Status if not null, and whatever value you want to slam in here (aka foo) if null
0
 
LVL 50

Accepted Solution

by:
Gustav Brock earned 300 total points
ID: 38831420
Use Nz:

  If Nz(Me.ProjectName) <> "" And Not IsDate(Me.AendDate) And Nz(Me.Status) <> "Cancelled"  Then
   Me.Status = "Working"
  End If

/gustav
0
 

Author Comment

by:DJPr0
ID: 38831464
Still not working:
(Working will not populate the status field on after update)

Private Sub Project_Name_AfterUpdate()
If "" & Me.ProjectName <> "" And IsDate(Me.AendDate) = False And Nz(Me.Status, "Cancelled") = False Then
        Me.Status = "Working"
End If
End Sub

Open in new window

0
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 

Author Comment

by:DJPr0
ID: 38831510
/gustav

This isn't working: (only works if Status has text)

 If Nz(Me.ProjectName) <> "" And Not IsDate(Me.AendDate) And Nz(Me.Status) <> "Cancelled"  Then
   Me.Status = "Working"
  End If
0
 
LVL 61

Expert Comment

by:mbizup
ID: 38831564
(No points, please)

Take another look at Jim's post.

You don't have the syntax quite right.  It should be:

 If Nz(Me.ProjectName) <> "" And Not IsDate(Me.AendDate) And Nz(Me.Status,"") <> "Cancelled"  Then
   Me.Status = "Working"
  End If

Open in new window

0
 
LVL 50

Expert Comment

by:Gustav Brock
ID: 38831626
Try with:

  If Nz(Me.ProjectName) <> "" And Not IsDate(Me.AendDate) And Nz(Me.Status, "Empty") <> "Cancelled"  Then
   Me.Status = "Working"
  End If

/gustav
0
 

Author Closing Comment

by:DJPr0
ID: 38831666
Thanks to everyone!

/gustav did work (when I put the code in the right form!)
0
 
LVL 50

Expert Comment

by:Gustav Brock
ID: 38831686
You are welcome!

/gustav
0
 
LVL 65

Expert Comment

by:Jim Horn
ID: 38831776
Thanks for the split.  Good luck with your project.  -Jim
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question