Set order by table property with VBA

M

Marshall Barton

Del said:
What code can I use to set and clear the Order By property of my table?


I don't think there is such a publicly available property.
Why do you care? you should not be using a table's
datasheet view for anything that cares about how a *table*
is sorted. If you want to display sorted data, you should
use a query.
 
D

Del

The MS VB Help topic 'OrderBy Property' states the following: "You can use
the OrderBy property to specify how you want to sort records in a form,
query, report, or table."

I was simply wondering how I could use this property.
 
L

Linq Adams via AccessMonster.com

I agree 100% with Marsh's comment about not using a table for
viewing/entering/editing data! But if you absolutely have to do so, open the
table in Design View, Right Click on the table's Title Bar, select
Properties and enter the field name you want to sort on in the OrderBy
Property. To sort by multiple fields, I think you separate the field names by
a comma.
 
M

Marshall Barton

Del said:
The MS VB Help topic 'OrderBy Property' states the following: "You can use
the OrderBy property to specify how you want to sort records in a form,
query, report, or table."

I was simply wondering how I could use this property.


It's not a very useful property.

Setting the property in a table's design view just means it
will be saved with the table so you can turn it on or off
using the Records - Apply Filter/Sort menu item.

In the Query design view, you would specify the sort order
using a field's Sort "cell". In SQL view, you use the Order
By clause. After the query is opened in datasheet view, you
can override that by using the Filter/Sort menu item, which
sets the OrderBy *property*. This temporary sorting can
then be turned on/off using Apply Filter/Sort. Personally,
I think this feature may be marginally useful when debugging
data.

For real user interactions, you should always use a form. A
form's OrderBy property is publicly available and can be set
using the menu or in VBA code. (The property is turned
on/off via the menu or the OrderByOn property.)

Reports are a different kind of critter. Sorting in a
report is primarily specified using the Sorting and Grouping
window (View menu). The OrderBy property is only applied
after that and is near useless.
 
Top