Zaff,
I didn't write that chapter, but it seems ReplaceOrderByClause() isn't provided in the text. Here's something I knocked up to get you out of trouble:
Public Function ReplaceOrderByClause(strSQL As String, strNewOrderByClause As String) As String
'Replace the OrderBy clause in an SQL string
Dim strSQLTmp As String
Dim intPos As Integer
intPos = InStrRev(UCase(strSQL), "ORDER BY", -1)
ReplaceOrderByClause = Left(strSQL, intPos + 8) & strNewOrderByClause
End Function
The above function does not take account of order direction (for example, ASC or DESC).
Graham R Seach
Microsoft Access MVP
|