OrderBy empty on ApplyFilter event

J

Jay

Version: Access 2007

I have a form with a button that does the following (VBA) when clicked:

Screen.PreviousControl.SetFocus
DoCmd.RunCommand (acCmdFilterMenu)

Then, I have code in the Form's ApplyFilter event, which is fired when (if)
the user clicks OK on the FilterMenu. In that code, I would like to
determine which field just had the OrderBy enabled.

If the form already has at least one field filtered, and the FilterMenu is
used to apply a sort order, Me.OrderByOn is true when the ApplyFilter event
occurs, but Me.OrderBy does not contain the new field to order by. It is
either empty (if no order was in place before) or it contains just the
previously ordered by fields. The problem occurs wheter or not the new
OrderBy field is one that was already filtered or one that was not already
filtered.

If the form does not have any fields filtered, Me.OrderByOn is true and
Me.OrderBy contains the new field to order by.

Any suggestions why this would happen or how to fix it? My workaround is to
assume that Screen.PreviousControl is the field that was just added to
OrderBy, but that doesn't allow me to determine if it was ascending or
descending order.

Jay
 

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