Share via

sort report based on checkbox

Anonymous
2012-06-22T22:48:38+00:00

Hi,

I want to sort a report where any record that has a checkbox that is not checked would appear first.

I have this code in the "order by" property:

Service_Completed, Service_Date

where Service_Completed is a checkbox field.

My report comes out with the records that are checked are first.  I want the non checked records to be first.

How do I change my order by property.  I tried "Not(Service_Completed)" and other things, but nothing worked.

Your help would be appreciated.

Thanks,

Phil

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

9 answers

Sort by: Most helpful
  1. Anonymous
    2012-06-23T17:50:18+00:00

    Hi

    Sorry, it is a form that I'm talking about. 

    If I set the form open event to:

    Abs([Service_Completed])

    the form does not sort.

    If I set the form open event to:

    Service_Completed

    The form sorts but with the checked boxes first.

    I don't know why the Abs function will not work but I want the unchecked box records to appear first..

    Any ideas?

    Thanks again,

    Phil

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2012-06-23T11:40:52+00:00

    In your first post you refer to a report, but in the last post to a form.  The method of sorting differs in each.  With a form you can either order the form's underlying query with:

    ORDER BY Abs([Service_Completed])

    or you can set the form's OrderBy property to:

    Abs([Service_Completed])

    and in the form's Open event procedure put:

    Me.OrderbyOn = True

    In a report you should use the report's internal Sorting and Grouping mechanism and create a group level on the expression Abs([Service_Completed]).

    This works because Access implements a Boolean TRUE as -1 and a FALSE as 0, so returning the absolute value with the Abs function allows the FALSE values to sort first as 0 sorts before 1.  If you regard this, as the head of one software company of my acquaintance calls it, as 'being unduly chummy with the implementation' you can use one of the following expressions:

    IIf([Service_Completed],1,0)

    or:

    Not [Service_Completed]

    or:

    ([Selected]=False)

    instead of calling the Abs function.

    Was this answer helpful?

    0 comments No comments
  3. Tom van Stiphout 40,211 Reputation points MVP Volunteer Moderator
    2012-06-23T05:00:52+00:00

    I was speaking of the query underlying your form.

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2012-06-23T04:55:48+00:00

    HI,

    Thanks for your response.  I using the "Order by" property of the form and I enter  "Not Service_Completed", save, view the form and return to properties and my order by is changed  to "[Not Service_Completed]" and the form is not sort by the Service_Completed field.

    Service_Completed is a checkbox field.

    Thanks,

    Phil

    Was this answer helpful?

    0 comments No comments
  5. Tom van Stiphout 40,211 Reputation points MVP Volunteer Moderator
    2012-06-23T04:10:00+00:00

    The parentheses are not needed:

    order by Not Service_Completed, Service_Date

    I am assuming Service_Completed is a Yes/No field.

    Was this answer helpful?

    0 comments No comments