在文本字段中排序的问题 [英] Problem with Sorting in a Text Field

查看:73
本文介绍了在文本字段中排序的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种按特定顺序对表单中的文本字段进行排序的方法。我在该领域的价值是1950.01.01 0r X1950.01.01他们现在排序为:

1950.01.01

1951.01.01

1952.01.01

X1950.01.01

X1951.01.01

X1952.01.01


我希望他们排序为:


1950.01.01

X1950.01.01

1951.01.01

X1951.01.01

1952.01.01

X1952.01.01


表单由一些查询控制表。是否可以在查询中对此字段进行排序?

I am looking for a way to sort a text field in my form in a specific order. The values I have in the field are either 1950.01.01 0r X1950.01.01 They now sort as:
1950.01.01
1951.01.01
1952.01.01
X1950.01.01
X1951.01.01
X1952.01.01

I want them to sort as:

1950.01.01
X1950.01.01
1951.01.01
X1951.01.01
1952.01.01
X1952.01.01

The form is controlled by a query that is pulling from several tables. Is it possible to sort this field in the query?

推荐答案

在计算字段上排序x。


我同意Rabbit。除了我的例子,可能有一种更简洁的方法来做到这一点,但要确保你得到X。非X后的记录,您可以在查询中添加计算字段,如下所示。然后对新列进行排序。

I agree with Rabbit. There is probably a cleaner way to do this than my example, but to ensure you get the "X" records after the non-X, you could add the calculated field in your query like the one below. Then sort on the new column.

展开 | 选择 | Wrap | 行号


感谢Rabbit和gnawoncents的响应!

我对编码知识非常有限,这是一个很好的帮助。事实上我甚至不知道你可以将这种代码放入查询中,所以谢谢。这解决了我在帖子中解释的问题,但是我没有解释得很好,所以我仍然没有得到我想要的订单(我的错)。我会尝试在这里给出一个更好的例子。数据库中有大约20,000条记录,并且该字段具有所有这些记录的唯一编号,并且每天都在增长。我在这个领域的数字是三个数字(1950.01.01)所以在1950年可以有01到无限制,在1950.01之内也可以有01到无限制。这是一个更好的例子:

1950.01.01

1950.01.02

1950.01.03

1950.01.04

1950.02.01

1950.02.02

1950.03.01

1950.03.02

1951.03.03

1952.03.04

等......


我需要的是所有1950年代来的在所有的X1950之前,然后所有的1951年,然后所有的X1951等。如果我没有X文件,我可以使用数字字段来解决问题。所以你提供的代码就是给我这个:


1950.01.01

X1950.01.01

1950.01.02
X1950.01.02

1950.01.03

X1950.01.03


我需要这个:


1950.01.01

1950.01.02

1950.01.03

X1950.01.01

X1950.01.02

X1950.01.03


有什么办法可以解决这个问题吗?
Thanks for the response Rabbit and gnawoncents!
I have very limited knowledge of coding and this is a great help. In fact I didn’t even know that you could put this kind of code into a query, so thanks. This fixes the problem that I explained in my post, however I did not explain it well enough and so I am still not getting the order that I want (my fault). I will try and give a better example here. There are about 20,000 records in the database and this field has a unique number for all of them and it grows every day. The number that I have in this field is a three part number (1950.01.01) so within 1950 there can be 01 to unlimited and within 1950.01 there can also be 01 to unlimited. Here is a better example:
1950.01.01
1950.01.02
1950.01.03
1950.01.04
1950.02.01
1950.02.02
1950.03.01
1950.03.02
1951.03.03
1952.03.04
and so on…

What I need is for all the 1950’s to come before all the X1950 and then all the 1951’s and then all the X1951 and so on. If I did not have the X-files I could us a number field and that would solve the problem. So the code you provided is giving me this:

1950.01.01
X1950.01.01
1950.01.02
X1950.01.02
1950.01.03
X1950.01.03

And I need this:

1950.01.01
1950.01.02
1950.01.03
X1950.01.01
X1950.01.02
X1950.01.03

Is there anything I can do to fix this problem?


这篇关于在文本字段中排序的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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