Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Queries / March 2008

Tip: Looking for answers? Try searching our database.

Sort with Nulls at End

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
QuadSquad - 06 Mar 2008 16:49 GMT
I have a table that I am trying to use a query to sort by Phone Number.  Some
of the records have no phone number, when I sort ascending it gives me the
records with no phone number first and then the populated ones.  I would like
to have it sorted with the nulls at the bottom.  I tried putting this

IIf(IsNull([CustomerPhone1]),"(999) 999-9999",[CustomerPhone1])

in my Criteria field but when I run the query it completely leaves out any
of the records with a blank phone number and just gives me the populated
ones.  What am I doing wrong?

Thanks.
Arica
Jerry Whittle - 06 Mar 2008 17:04 GMT
Put it in a field on top and not in the criteria. Also make sure to sort on
that field. If you don't want to display the 999's, uncheck the display box.
You can still sort on it even if not shown in a query. However if the query
is going to drive a report, you'll need it for the sorting and grouping
options in the report. However the field could be invisible.
Signature

Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.

> I have a table that I am trying to use a query to sort by Phone Number.  Some
> of the records have no phone number, when I sort ascending it gives me the
[quoted text clipped - 9 lines]
> Thanks.
> Arica
John Spencer - 06 Mar 2008 17:17 GMT
The expression should not be a criteria.  It should be put in as a
calculated field and then sort on the calculated field.  You don't have to
show the field.

Another option would be to use a calculated field and sort by it and then by
the phone number
Field: NoPhone: CustomerPhone1 is Null
Sort: Descending

Signature

John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
.

>I have a table that I am trying to use a query to sort by Phone Number.
>Some
[quoted text clipped - 11 lines]
> Thanks.
> Arica
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.