如何为我的表指定默认排序顺序(非主键)? [英] How to specify a default sort order (non-primary key) for my table?

查看:73
本文介绍了如何为我的表指定默认排序顺序(非主键)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个以两种形式出现的表:在一种形式中,它是控制,但在另一种形式中,它从属于另一个表(一对多关系)。在第二种形式中,我想要多的形式。要通过日期字段(不是主键)排序的从属表的记录。


我可能在想这一切都错了,但我认为在某处该日期字段的定义(甚至是子表单上的某个地方)我将能够指定它是排序键。我知道我可以做一个查询的事情,但这似乎是一个巨大的矫枉过正。现在只要打开桌子上的表格,一切都很顺利,除此之外。


我觉得真的很愚蠢地问这个问题,因为看起来它一定是盯着我的脸,但是我该怎么办呢?


(编辑:我的表'的属性当前有'Order By'设置为'IURs。[Receive Date] DESC",我原本以为是诀窍,但没有。)

I have a table that appears in two forms: in one form, it is the "control", but in the other form, it is subordinate to another table (one-to-many relationship). In that second form, I want the "many" records of the subordinate table to be ordered by a date field (which is not the primary key).

I''m probably thinking about it all wrong, but I assumed that somewhere in the definition of that date field (or even somewhere on the subform) I''d be able to specify that it''s the "sort key". I know I could do a query thing, but that seems like enormous overkill. Everything fits together so smoothly right now just opening the tables in the forms, except for this.

I feel REALLY dumb asking this question because it seems like it must be staring me in the face, but how do I do this?

( My table''s Properties currently has "Order By" set to "IURs.[Receive Date] DESC", which I would have thought was the trick, but no.)

推荐答案

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


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


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


-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.)


这篇关于如何为我的表指定默认排序顺序(非主键)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆