Share via

Sort query by checkbox

Anonymous
2012-11-06T06:27:55+00:00

Below is the SQL for my query. Is there any way to sort this so that the checkbox cleared is not checked it will sort to the top?

SELECT tblMissingCards.MissingCardID, tblMissingCards.EmpID, tblMissingCards.Cleared, tblMissingCards.MissingDates, tblMissingCards.ReasonID, tblMissingCards.SubmittedDate, tblMissingCards.SubmittedBy

FROM tblMissingCards

WHERE (((tblMissingCards.EmpID)=[Forms]![frmNavigationForm].[NavigationSubform].[Form]![cboSearchName]))

ORDER BY tblMissingCards.Cleared;

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

1 answer

Sort by: Most helpful
  1. HansV 462.6K Reputation points
    2012-11-06T07:30:14+00:00

    If a check box is ticked, its value is True = -1. If it is clear, its value is False = 0. To sort the False values before the True values, you must sort descending:

    ...

    ORDER BY tblMissingCards.Cleared DESC;

    Was this answer helpful?

    2 people found this answer helpful.
    0 comments No comments