Results 1 to 4 of 4
  1. #1
    Lounger
    Join Date
    Jul 2002
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Set OrderBy Property of Table Using VBA? (Access 2000)

    Is there any way to set the OrderBy property of a table using Visual Basic?

  2. #2
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,623
    Thanks
    3
    Thanked 60 Times in 60 Posts

    Re: Set OrderBy Property of Table Using VBA? (Access 2000)

    You should be able to set it using the TableDef collection - though I can't think of a reason to ever do it. That's the property that get's set when you sort a table on the fly, and only very rarely do we even let the user see the tables directly.
    Wendell

  3. #3
    3 Star Lounger
    Join Date
    May 2002
    Location
    Toronto, Ontario, Canada
    Posts
    314
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Set OrderBy Property of Table Using VBA? (Access 2000)

    I can't seem to find a way to do this for a table... Not with a simple VB statement anyway... The OrderBy and OrderByOn properties are available for forms and reports, but not tables (from what I can see... ) One way you could change the order temporarily would be to use an SQL statement with an Order By clause in your code......

    Using DAO the code would look something like this...

    Dim db as dao.database
    Dim rst as dao.recordset
    Set db = CurrentDb
    Set rst = db.OpenRecordset("Select * From TableName Order By FieldName;")

    I believe this would order it properly for you to work with but it's not going to be a permanent change to the table design...
    HTH

  4. #4
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Set OrderBy Property of Table Using VBA? (Access 2000)

    What are you trying to accomplish? Tables are normally sorted by their primary key. If you want to present the data to your users, use a query and set the Order By in the SQL.
    Charlotte

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •