Code to restore Order By property of a query at runtime

  • Thread starter Microsoft Newsgroups
  • 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.
 
A

Allen Browne

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

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

Mark Hammer

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top