I am writing an SQL statement to generate a query and then open a report:
' Run the query and report
MyDB.QueryDefs.Delete "qryCustom"
Set qdf = MyDB.CreateQueryDef("qryCustom", strSQL)
DoCmd.OpenReport "rptCustom", acPreview
my SQL statement ends with an ORDER BY statement and the fieldnames can change based on the form decision
strSQL = ... ORDER BY getFieldName(Me.sort0) ASC, getFieldName(Me.sort1) ASC
However when I run the code and the report opens the data isn't sorted. Why doesn't this work?
' Run the query and report
MyDB.QueryDefs.Delete "qryCustom"
Set qdf = MyDB.CreateQueryDef("qryCustom", strSQL)
DoCmd.OpenReport "rptCustom", acPreview
my SQL statement ends with an ORDER BY statement and the fieldnames can change based on the form decision
strSQL = ... ORDER BY getFieldName(Me.sort0) ASC, getFieldName(Me.sort1) ASC
However when I run the code and the report opens the data isn't sorted. Why doesn't this work?