8wDlpd.png
8wDFp9.png
8wDEOx.png
8wDMfH.png
8wDKte.png

根据组合框文本(而不是组合框编号)对 Access 连续表单上的字段进行排序

KJ Sudarshan 1月前

29 0

我在表中有一个列表 \'Task-TrainingStatus\'Id Priority1 Medium2 Low3 High4 Lowest5 N/A6 Highest 我的数据表 \'Task-TrainingList\' hasId PriorityLevel1 32 3...

I have a list in a table "Task-TrainingStatus"

Id  Priority
1   Medium
2   Low
3   High
4   Lowest
5   N/A
6   Highest


My data table "Task-TrainingList" has

Id PriorityLevel
1       3
2       3
3       6
4       2
5       1
6       2
7       4
8       5

I have a continuous form "TrainingList" that has a combobox "cboxPriority" 
Control Source : PriorityLevel
Row Source : SELECT [Task-TrainingStatus].[ID], [Task-TrainingStatus].[Priority] FROM [Task-TrainingStatus] ORDER BY [Priority]; 
Bound Column: 1
Column Count: 2
Column Widths: 0";1"
The combobox acts as expected, it shows low, lowest, Medium, etc...

I have a label "lblPriority" with an on click event (simplified)
Private Sub lblPriority_Click()
    Me.OrderBy = "PriorityLevel"
    Me.OrderByOn = True
End Sub
The problem is that it sorts based on the numeric Id so I get:
Medium
Low
High
Lowest
N/A
Highest

and I want it to sort by the text

High
Highest
Low
Lowest
Medium
N/A

The sort is based on the underlying table value and I can't figure out how to get from there to the text value.

How do I do it?

帖子版权声明 1、本帖标题:根据组合框文本(而不是组合框编号)对 Access 连续表单上的字段进行排序
    本站网址:http://xjnalaquan.com/
2、本网站的资源部分来源于网络,如有侵权,请联系站长进行删除处理。
3、会员发帖仅代表会员个人观点,并不代表本站赞同其观点和对其真实性负责。
4、本站一律禁止以任何方式发布或转载任何违法的相关信息,访客发现请向站长举报
5、站长邮箱:yeweds@126.com 除非注明,本帖由KJ Sudarshan在本站《sorting》版块原创发布, 转载请注明出处!
最新回复 (0)
  • 您的表单需要使用查询作为记录源:

    SELECT [Task-TrainingList].ID, 
           [Task-TrainingList].PriorityLevel, 
           [Task-TrainingStatus].Priority
    FROM [Task-TrainingList] 
    INNER JOIN [Task-TrainingStatus] ON [Task-TrainingList].ID = [Task-TrainingStatus].ID;
    

    然后,您可以将 OrderBy 表单上的属性设置为, Priority 或者作为替代方案,您可以对查询中的数据进行排序:

    SELECT [Task-TrainingList].ID, 
           [Task-TrainingList].PriorityLevel, 
           [Task-TrainingStatus].Priority
    FROM [Task-TrainingList] 
    INNER JOIN [Task-TrainingStatus] ON [Task-TrainingList].ID = [Task-TrainingStatus].ID
    ORDER BY [Task-TrainingStatus].Priority;
    
返回
作者最近主题: