Share via

Sorting an existing msaccess table

Anonymous
2022-03-01T21:39:29+00:00

Dear all,

I have built an access database with some tables.

I'm wondering If there is a way to sort these table by vba or by using an internal database query

Thanks

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

3 answers

Sort by: Most helpful
  1. Anonymous
    2022-03-02T17:15:48+00:00

    Thanks all for your feedback!

    I totally agree with everybody but I was asking to sort programmatically by VBA because I did not want to rebuild the database to create a Sort index on each table.

    That's why I was preferring to do it quickly by VBA ;-)

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2022-03-02T10:16:41+00:00

    ciao Luca,

    I completely agree with Scott.

    To add some more words...

    Sometimes, people think about Access tables like a Excel spreadsheets where sorting is easy to apply in some columns, but they are totally different, even if similar in their views.

    Moreover, a table is a set and set has no order : this is one main and important rule regarding relational databases, relational theory and model.

    This means to sort your datas you need to apply order by clause using queries, or by order by clause available in access forms.

    We have just scratched the surface....

    HTH and ciao, Sandro.

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2022-03-01T23:57:42+00:00

    Hi Luca, I will try to help.

    Any query can be sorted. SQL Has an ORDER BY clause that can specify a sort. Or, you can use the query grid to specify a sort in the Sort row. If you use the query grid the sort is performed left to right. Generally sorting is done in queries, not directly in tables. Also generally, users should not directly access tables, so there seems no good reason to sort a table using VBA. In over 25 years of Access development, I have never even thought to try it.

    If you need further clarification on this feel free to ask.

    Was this answer helpful?

    0 comments No comments