Apply a Sort

  • Thread starter Thread starter WorkerBee
  • Start date Start date
W

WorkerBee

Guest
Hello Everyone

I have a form with a "Keyword Search" This functions great. It applies a filter when I do the search. Which is what I want.
But when I'm done, I want the filter removed. I can do this with a macro "ShowAllRecords". This works fine when I click on the command button it is applied to. The only thing is, it is no longer sorted by the "Auto" number field :( . I would like this to be done automatically when I remove the filter.

Is there any way to do this without clicking on my field, and then clicking on the "sort" button on the toolbar?

Thanks for any help.

:p Up to now, I've been able to find the answers to my questions by doing a search on this forum.
So thanks to everyone who has been answering everyone's questions

Joy
 
Hi
Could You Attach sample Of Your Work?
 
Joy,

base your form on a query.
Sort within your query.

RV
 
I got the code for the keyword search from this forum.

Private Sub SearchKeyWord_Click()
Dim stDocName As String
Dim stLinkCriteria As String

If IsNull([KeyWords]) Then
MsgBox "Please key some text before searching", vbOKOnly + vbCritical, "Free Text Search Missing"
[KeyWords].SetFocus

Else

stDocName = "projects--no entry code"

stLinkCriteria = "[KeyWords]LIKE" & "'*'&" & "'" & Me![KeyWordSearchBox] & "'" & "&'*'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.Close acForm, "KeywordSearchForm"

Exit_SearchKeyWord_Click:
Exit Sub

Err_SearchKeyWord_Click:
MsgBox Err.Description
Resume Exit_SearchKeyWord_Click
End If
End Sub

The above code works great. Exactly as I want it to.
When I remove the filter (with a "showAllRecords" macro attached to a command button), the form is no longer sorted by the "auto" field.

Thanks Joy
 
Thank you very much

I went back and looked at my query, it had the wrong field listed for sorting. I changed it to the field I wanted, and now when I remove the filter, it sorts as I want it too. :)

I looked all over my form, but had to go back further to correct the problem. So simple a fix. I was looking for something complicated! :rolleyes:

Thank you for your time and your patience

Joy
 

Users who are viewing this thread

Back
Top Bottom