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

W

WebDude

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!
 
W

WebDude

Ken,

Is there a difference between,

Me.FilterOn = False
and
DoCmd.ShowAllRecords

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

Cheers,
WebDuuuuuuuude.
 

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