Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2013-01-29
9
Medium Priority
?
419 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
  • 3
  • 3
  • 2
  • +1
9 Comments
 
LVL 66

Assisted Solution

by:Jim Horn
Jim Horn earned 800 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 52

Accepted Solution

by:
Gustav Brock earned 1200 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
Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

 

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 52

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 52

Expert Comment

by:Gustav Brock
ID: 38831686
You are welcome!

/gustav
0
 
LVL 66

Expert Comment

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

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Suggested Courses

972 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