我在表中有一个列表 \'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?
爱
您的表单需要使用查询作为记录源:
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;