Microsoft KB Archive/837148

= BUG: You may notice an incorrect sorted order when you sort the negative decimal values in descending order in Access =

Article ID: 837148

Article Last Modified on 7/28/2006

-

APPLIES TO


 * Microsoft Office Access 2003
 * Microsoft Access 2002 Standard Edition
 * Microsoft Access 2000 Standard Edition

-



This article applies only to a Microsoft Access database (.mdb).

Moderate: Requires basic macro, coding, and interoperability skills.



SYMPTOMS
When you sort the records in a Number field in descending order, and the Field Size property of the Number field is set to Decimal, you may notice that the negative values in the field are not sorted in the correct order. This problem occurs in a Microsoft Access table.

For example, you can sort a Number field in descending order that contains the following data:

20, -10, 5, -5, 10, -20

After you sort the Number field in descending order, you may notice that the sorted data appears in the following order:

-5, -10, -20, 20, 10, 5



WORKAROUND
To work around this problem, create an index on the Number field before you sort the records in the Number field. To do this, follow these steps:
 * 1) Start Access.
 * 2) Open your Access database.
 * 3) In the Database window, click Tables under the Objects section.
 * 4) In the right pane, right-click the table that contains the problem field, and then click Design View.
 * 5) Select the problem field.
 * 6) In the Field Properties section, set the value of the Indexed property to Yes (Duplicate OK).
 * 7) On the File menu, click Save.
 * 8) On the View menu, click Datasheet View.
 * 9) Select the problem field.
 * 10) On the Records menu, point to Sort, and then click Sort Descending.

Notice that the sorted data appears in the correct order.



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.



Steps to reproduce the problem
 Start Access. Open the Northwind.mdb sample database. In the Database window, click Tables under the Objects section. In the right pane, double-click Create table in Design view.  Create a table that is named TestTbl that has two fields that are named fldID and fldNumber. Set the properties of the fields as follows:

 Table: TestTbl Field Name  : fldID Data Type   : AutoNumber

Field Name  : fldNumber Data Type   : Number Field Size  : Decimal

Table Properties: TestTbl ---  PrimaryKey: fldID </li> On the File menu, click Save.</li> In the Save As dialog box, type TestTbl in the Table Name box, and then click OK.</li> On the View menu, click Datasheet View.</li> Enter the following data in the fldNumber field:

20, -10, 5, -5, 10, -20</li> Select the fldNumber field.</li> On the Records menu, point to Sort, and then click Sort Descending.

Notice that the sorted data appears in the incorrect order.</li></ol>

<div class="references_section">