Solved

MSAccess: Date Sort, Nulls to Bottom?

Posted on 2009-05-06
5
255 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 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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…
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

733 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