DoCmd.ApplyFilter

jayclifford

Registered User.
Local time
Today, 01:26
Joined
Jul 23, 2013
Messages
16
I want to use buttons on a form to change the sort order on a continuous form. In the buttons click event I am using a public function (named Sort_1) to change the sort order. The first element of the event call is the name of a generic query (named Sort_1_Query1) and the query field to sort (LAST_NAME OR FRIST_NAME, depending on the button.)
This is the Click Statement.

=Sort_1("Sort_1_Query1","LAST_NAME")

This is the Public Function
Public Function Sort_1(SortName As String, FieldName1 As String)
DoCmd.ApplyFilter SortName, FieldName1 & "between 'A' and 'Z'"
End Function

This does not work!
I think the problem is in the use of quotation marks or trying to pass the query field name to the Do Command or the use of an ampersand. HELP!
 
You're trying to apply a Sort using the ApplyFilter function, that won't work, two different things. Have a look at...

http://regina-whipp.com/blog/?p=578

While the above uses Labels you can do the same thing with a Command Button.
 
I see what the link is doing. According to the help files (which MS provides, in abbreviated form) the ApplyFilter can either be used as a filter or a sorting device, what do they mean? I certainly can use the code in your link and I thank for it; still.
 
LOL... and I'm not laughing at you but those Help-LESS files make me crazy! :banghead: Forget them, you need help ask here! ApplyFilter does just that, it applies a Filter, no more no less. If you happen to get lucky and they happen to Sort along the way great BUT it would be pure luck.

Been complaining for years about those Help files, either you nothing or you get MIS-information! Sometimes you get the correct the information BUT, like everything else, get a second opinion!
 

Users who are viewing this thread

Back
Top Bottom