Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I am trying to sort a column ascending with zero fields

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
0
0
I am trying to sort a column that has null fields in it. I need to sort the field ascending while the null fields stay in order. Example: first field has a 6 and then the next 6 fields are empty then the next field has a 5 and the next 5 fields are empty. I need to keep the empty fields where there are while sorting the numeric fields in ascending order
 
I don't think you will be able to do this. If sorting ascending, the nulls (empty) fields will be at the top (first), then numeric 0,1,2,3 ect..............

HTH
RDH [sig]<p>Ricky Hicks<br><a href=mailto: rdhicks@mindspring.com> rdhicks@mindspring.com</a><br><a href= > </a><br> [/sig]
 
Depending upon your final objective, you may be able to accomplish your goal by using VBA to,
1. Create a copy of the original table
2. Create a new column in the copied table
3. Add numbers to the new column that reflect your
desired sort order, ie. for every &quot;blank&quot;, use the
number of the record above it. Then do a sort on
your revised column to get the desired order.
Finally, strip out the added column
It may seem like a lot of work, but it might get the job done for you.
[sig][/sig]
 
Thanks for all of your help guys. I did get the column sorted but it entailed using two different queries and using and multiple fields.

Part 1 of query to sort ascending with null fields:
SELECT NSBA.PIN, NSBA.[Code 2], NSBA.Multiples
FROM NSBA
WHERE (((NSBA.[Code 2])=&quot;CLERK&quot;))
ORDER BY NSBA.Multiples;

Part 2 of query to sort ascending with null fields:
SELECT NSBA.*
FROM NSBA, Query1
ORDER BY Query1.Multiples, Query1.[Code 2], NSBA.ID;

it was difficult to figure out but i got the job done.....Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top