Solved

MSAccess: Date Sort, Nulls to Bottom?

Posted on 2009-05-06
5
226 Views
Last Modified: 2012-05-06
Hello,

I've place a collection of radio buttons on a form to permit various sorting options.  One of them is to sort on a date field.  I have attempted to sort ascendingm with NULLS at teh bottom using the following approach:

Forms!MainForm![QAReport subform].Form.OrderBy = "nz([Due to Client],'ZZZ') ASC"

This does move the NULLS to the bottom, but the dates are not sorting correctly.  Here is a sample - close but not quite:

Due From QA
5/26/2009
5/27/2009
5/28/2009
5/29/2009
5/30/2009
5/6/2009
5/7/2009
5/8/2009
5/8/2009
5/9/2009
5/9/2009
5/9/2009
6/1/2009
6/11/2009
6/16/2009
6/16/2009

Any suggestions?

Mark
0
Comment
Question by:markp99
  • 3
  • 2
5 Comments
 
LVL 57
ID: 24316174
<<Any suggestions?>>
is [Due to client] a text field or a date/time field?
JimD.
0
 

Author Comment

by:markp99
ID: 24316250
This is a date/time field from an external (linked) SQL table. If I right click on the column header and sort, dates are sorted correctly with NULLS at the top.
0
 
LVL 57

Accepted Solution

by:
Jim Dettman (Microsoft MVP/ EE MVE) earned 500 total points
ID: 24316336
Change to this:
Forms!MainForm![QAReport subform].Form.OrderBy = "CDat(nz([Due to Client],'12/31/2999')) ASC"
and create another column in your underlying data source defined as:
nz([Due to Client],' ')
 and display that in the form.  You should get the right sorting then.
JimD.  
0
 

Author Closing Comment

by:markp99
ID: 31578567
Simply using:

Forms!MainForm![QAReport subform].Form.OrderBy = "CDate(nz([Due to Client],'12/31/2999')) ASC"

Solved my issue.

Thanks.
0
 
LVL 57
ID: 24317450
Yes, the first change would take care of the sort, but I didn't think you'd want to see 12/31/2999 in place of the NULLs in you date column which is why I suggested defining a new column for display.
JimD.
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

744 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now