Code to restore Order By property of a query at runtime

  • Thread starter Thread starter Microsoft Newsgroups
  • Start date Start date
M

Microsoft Newsgroups

Access XP here, if it matters.

User opens a Select query in datasheet view and does a manual sort on a
field. Close, reopen, and Access remembers the sort order.

How can I reset that in code at runtime, so that my original sort
instructions from the QBE grid are restored?

To clear the query properties Order By property, I tried this:

Dim qdf as DAO.Recordset
Set qdf=CurrentDB.QueryDefs("MyQuery")
qdf.OrderBy=""

Access didn't like the last line, qdf.OrderBy = ""

Help appreciated.

Mark Hammer
Lake Oswego, Oregon, U.S.
 
Try:
CurrentDb.QueryDefs("MyQuery").Properties.Delete "OrderBy"

Use error handling to recover from error 3265 if property doesn't exist.
 
Bingo! Thanks Allen.

--Mark Hammer


Allen Browne said:
Try:
CurrentDb.QueryDefs("MyQuery").Properties.Delete "OrderBy"

Use error handling to recover from error 3265 if property doesn't exist.
 
Back
Top