Forum Discussion

LizHATW2000's avatar
LizHATW2000
Copper Contributor
Mar 02, 2021

Record order shuffles spontaneously!

I'm using a membership database. The main contacts form is used to enter data. The query that populates this form is sorted on ID (prime key). Initially the forms appear in ID order and I've opened and closed the database several times then, spontaneously, the records will shuffle and appear in random order.  The query is consistently in ID order. I'm trying to clean the data so this is driving me mad! Can anyone advise how to fix this? The database is written in Access 2000/2 and I am using MS365.

  • George_Hepworth's avatar
    George_Hepworth
    Silver Contributor

    LizHATW2000 

    Tables in relational database applications--like Access--have no inherent sort order. If you must have records presented in a specific order, then you must use an ORDER BY clause in a query to impose that sort order. You can not, in other words, count on your query to consistently sort on ID unless you add that ORDER BY clause to the query: ORDER BY ID

    • LizHome2000's avatar
      LizHome2000
      Copper Contributor
      Thanks George. I sent this to my colleague who wrote the database. I don't know exactly what he did but he wrote me a new query which will do the job and won't go wrong. Thanks for your help.
      • George_Hepworth's avatar
        George_Hepworth
        Silver Contributor
        Congratulations on solving the problem.
        Continued success with the project.

Resources