Adding an ORDER BY to a filter in VBA..?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi again :-)

Am i pusing the enevelope to far this time
with the following code?




Dim strSortUsing As String
...
strSortUsing = "[FirstName]"
...
Me.Filter = strSortUsing & "like 'K*'" & " ORDER BY " & strSortUsing
Me.FilterOn = True
...




The code is from a button, on a continous form, whose record source is a
table/query where [FirstName] is a field.

When pressing the button, the form filters out all records where
[firstname] = like 'K*'


However, MS ACCESS did not like the..

& " ORDER BY" & strSortUsing


So,as an alternative, i set the forms me.orderby property
to strSortUsing then set me.orderbyon = true.

But i find having to use the forms orderby property
to sort a filter is rather redundant (if the filters are
indeed able to sort fields themselves- right?).

Cheers,
WeeeeeeeebDude!
 
Ken,

Is there a difference between,

Me.FilterOn = False
and
DoCmd.ShowAllRecords

...both seem to remove the filter and return all records.

Cheers,
WebDuuuuuuuude.
 
Back
Top