且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何为我的表指定默认排序顺序(非主键)?

更新时间:2023-11-24 13:00:28

嗨苏。通常,表单应基于查询而不是直接基于底层表。使用查询,您可以指定所需的排序顺序,完全独立于表的主键和索引设置。


我建议您在相关表上定义查询,包括该表的所有字段,然后将相关的日期字段设置为升序(最早的第一个)或降序(最新的第一个),然后将表单基于查询而不是表格。


如果需要,您还可以使用查询对多个字段进行排序 - 在您的订购中引入分组。


-Stewart
Hi Sue. Generally, forms should be based on queries rather than directly on the underlying tables. Using a query you can specify whatever sort order you want, completely independent of the table''s primary key and index settings.

I would suggest that you define a query on the table concerned, include all of the fields for that table, then set the relevant date field into either Ascending order (oldest-first) or Descending order (newest first), then base your form on the query rather than on the table.

You can also use the query to sort on multiple fields if you want - introducing grouping into your ordering.

-Stewart

>

此外,表单有一个 Order By 属性,如果排序特定于该表单,您可以使用它,并且您不希望它成为绑定表的其他用途的默认值或查询。它还支持按多个字段排序。
Also, forms have an Order By property that you can use if the ordering is specific to that form and you don''t want it to be the default for other uses of the bound table or query. It also supports sorting by multiple fields.


好的,这听起来像是我要来的。我想我只是有点懒,但我可以看到使用查询而不是裸表可能值得额外一步。


谢谢,你们俩 - 我我会着手这样做。


(哦,我确实将Order By属性设置为使用我想要的字段,但我仍然没有得到我期望的结果。我确定所有这些麻烦都将通过查询修复。)
Okay, that sounds like what I was sort of coming to. I guess I was just being a bit lazy, but I can see that using a query instead of the bare table is probably worth the extra step.

Thanks, both of you--I''ll set about doing that.

(Oh, and I actually do have the "Order By" property set to use the field I want, but I still wasn''t getting the result I expected. I''m sure all these troubles will be fixed using a query.)