Solved

MSAccess: Date Sort, Nulls to Bottom?

Posted on 2009-05-06
5
260 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
[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
  • 2
5 Comments
 
LVL 58
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 58

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 58
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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

705 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