如何按联合查询的降序对表单中的记录进行排序

时间:2015-06-08 19:08:43

标签: sql access-vba ms-access-2010

下面的代码假设是创建一个查询和提要表单'frmstaticdatadepartments08'我试图根据字段tblContacts.TotalTeamSkills按降序对记录进行排序。不幸的是,这种方式无效。

 sql_get = "SELECT tblContacts.Group, tblTeams.ID as TeamID, tblValueChain01.MacroProcess, tblTeams.Team, tblContacts.CompleteName, tblContacts.Foto, tblContacts.CurrentPosition, tblContacts.Level, tblContacts.ContractType, tblContacts.Beginner, tblContacts.SemiSkilled, tblContacts.HighlySkilled, tblContacts.Expert, tblContacts.totalskills, tblContacts.TeamBeginner, tblContacts.TeamSemiSkilled, tblContacts.TeamHighlySkilled, tblContacts.TeamExpert, tblContacts.TeamTotalSkills, tblContacts.DeptBeginner, tblContacts.DeptSemiSkilled, tblContacts.DeptHighlySkilled, tblContacts.DeptExpert, tblContacts.DeptTotalSkills, tblContacts.TotalActiveSkills, tblContacts.TotalTeamSkills, tblContacts.TotalDeptSkills, tblcontacts.flag1, tblcontacts.flag2, " & _
    "tblcontacts.JobTitle FROM tblJobTitles INNER JOIN ((tblContacts INNER JOIN tblTeams ON tblContacts.Team = tblTeams.ID) INNER JOIN tblValueChain01 ON tblContacts.Group = tblValueChain01.IDMacroProcesso) ON tblJobTitles.jobtitle = tblContacts.JobTitle WHERE ([tblvaluechain01].[macroprocess]= '" & cboTeams.Value & "') or ([tblcontacts].[group]= 38 and [tblteams].[team]= '" & cboDepartments.Value & "') ORDER BY tblContacts.TotalTeamSkills DESC;"
    Me.frmstaticdatadepartments08.Form.RecordSource = sql_get

1 个答案:

答案 0 :(得分:2)

如果您没有收到任何类型的错误消息,我的资金就是您的frmstaticdatadepartments08已经有Order By字段。将其放入设计视图并查看表单Properties窗格,如果它未打开,您可以使用Alt + Enter打开它。如果有任何设置要排序在那里删除它。

此外,该命名方案......请为将来修复它。