A little more clarification, then will show some more code: I can open this Access file (.mdb), which is on our group's network drive, from my computer with Access 2007 and from my new computer with Access 2010. The sorting runs perfectly when I use Access 2007 to open the file, but no sorting when use Access 2010 version.
My code consists of an SQL string that 1) begins with Select clause, 2) then program goes through all fields on dialog form where user specified Where attributes, 3) and finally, last part of code is the Sorting portion that is based again on dialog form where user specificed what field(s) to sort on. The report runs in both 2010 and prior versions, except that sorting does not take in 2010 version:
1) Select Clause: (variables have already been dimensioned above this code)
strSQL = "SELECT TotalTrans.NC, TotalTrans.RESP, TotalTrans.NCRESP, " _
& " TotalTrans.RevItm as RevItm, TotalTrans.AMOUNT, TotalTrans.AbsAmt," _
& " TotalTrans.DATE, TotalTrans.PERIOD, TotalTrans.JOB, TotalTrans.SUB, TotalTrans.JOBSUB, " _
& " TotalTrans.[OR Ref #]," _
& " TotalTrans.OFC, TotalTrans.CO, TotalTrans.SOURCE_REF, TotalTrans.LINE_ITEM, " _
& " TotalTrans.SRC_CD, GroupPool.Group, GroupPool.Pool," _
& " SourceCodeDesc.SRC_DESC, TotalTrans.[Other Amt], TotalTrans.[Summary Analysis]," _
& " TotalTrans.[Date Reviewed], TotalTrans.[OtherCause],TotalTrans.[Reviewed By], " _
& " TotalTrans.Reviewed, TotalTrans.MemoAdjAmt," _
& " [Joblist].JOB_DESC, [Joblist].SJOB_DESC, NCLookupWithSummary.NC_Description, " _
& " GroupPool.Group, GroupPool.Pool, GroupPool.EX " _
& " FROM (((((TotalTrans LEFT JOIN [Joblist] ON TotalTrans.JOBSUB = [Joblist].JOBSUB)" _
& " LEFT JOIN SourceCodeDesc ON TotalTrans.SRC_CD = SourceCodeDesc.SRC_CD)" _
& " LEFT JOIN NCLookupWithSummary ON TotalTrans.NC = NCLookupWithSummary.NC)" _
& " LEFT JOIN PriorityCd ON TotalTrans.NCRESP = PriorityCd.NCRESP) " _
& " LEFT JOIN GroupPool ON TotalTrans.Jobsub = GroupPool.Jobsub) "
2) Where clause is built up as vba goes through each field on dialog form and based on null or not null, updates Where clause
3) Sort code: I generally use two levels of sort (cmbSort1 and cmbSort2) but even with one level version 2010 does not sort correctly.
' ----------------------------- Begin Sort Order -----------------------------
intSort = 0
If Forms![DesignYourOwnReportDialog].cmbSort1 <> "" Then intSort = intSort + 1
If Forms![DesignYourOwnReportDialog].cmbSort2 <> "" Then intSort = intSort + 2
If Forms![DesignYourOwnReportDialog].cmbSort3 <> "" Then intSort = intSort + 4
Select Case intSort
Case 0
MsgBox "Sort criteria not specified; therefore " & vbCrLf & "report to be sorted AbsAmt / Date.", vbInformation, "Alert"
Me.OrderBy = "TotalTrans.AbsAmt DESC, TotalTrans.DATE"
strSQL = strSQL & " ORDER BY TotalTrans.AbsAmt DESC, TotalTrans.DATE;"
strSortBy = "AbsAmt DESC / Date"
Case 1
strSort1 = Forms![DesignYourOwnReportDialog].cmbSort1
Me.OrderBy = "TotalTrans." & strSort1
strSQL = strSQL & " ORDER BY TotalTrans." & strSort1 & ";"
strSortBy = strSort1
Case 3
strSort1 = Forms![DesignYourOwnReportDialog].cmbSort1
strSort2 = Forms![DesignYourOwnReportDialog].cmbSort2
Me.OrderBy = "TotalTrans." & strSort1 & ", TotalTrans." & strSort2
strSQL = strSQL & " ORDER BY TotalTrans." & strSort1 & ", TotalTrans." & strSort2 _
& ";"
strSortBy = strSort1 & " / " & strSort2
Case 7
strSort1 = Forms![DesignYourOwnReportDialog].cmbSort1
strSort2 = Forms![DesignYourOwnReportDialog].cmbSort2
strSort3 = Forms![DesignYourOwnReportDialog].cmbSort3
Me.OrderBy = "TotalTrans." & strSort1 & ", TotalTrans." & strSort2 _
& ", Totaltrans." & strSort3
strSQL = strSQL & " ORDER BY TotalTrans." & strSort1 & ", TotalTrans." & strSort2 _
& ", Totaltrans." & strSort3 & ";"
strSortBy = strSort1 & " / " & strSort2 & " / " & strSort3
Case Else
MsgBox "Sort criteria must start w/ Box 1, then 2, etc." & vbCrLf & "Report to be sorted AbsAmt / Date.", vbInformation, "Alert"
Me.OrderBy = "TotalTrans.AbsAmt DESC, TotalTrans.DATE"
strSQL = strSQL & " ORDER BY TotalTrans.AbsAmt DESC , TotalTrans.DATE;"
strSortBy = "AbsAmt DESC / Date"
End Select
' Debug.Print "strSql" & vbCrLf & strSql 'For Testing
Me.RecordSource = strSQL
Me.OrderByOn = True
DoCmd.Hourglass False
'Set public variable to False, signifying that Open event is finished.
blnOpening = False
End Sub