Question on Allen Browne's Search form (adding a sort)

G

Guest

For those of you not familiar with the code, I've added a snippet to show you
what it looks like:

Private Sub cmdFilter_Click()
Dim strWHERE As String
Dim lngLen As Long
Const conJetDate = "\#mm\/dd\/yyyy\#"


If Not IsNull(Me.cboControlCode) Then
strWHERE = strWHERE & "([GroupID] = """ & Me.cboControlCode & """) AND "
End If

If Not IsNull(Me.txtQuickNote) Then
strWHERE = strWHERE & "([QuickNote] Like ""*" & Me.txtQuickNote & "*"")
AND "
End If

lngLen = Len(strWHERE) - 5

If lngLen <= 0 Then
MsgBox "No criteria selected", vbInformation, "No Search Criteria"
Else
strWHERE = Left$(strWHERE, lngLen)
Debug.Print strWHERE
Me.Filter = strWHERE
Me.FilterOn = True
End If

End Sub

I wanted to be able to add a sort to the data, and starting and tried to add
the following statement to the end of the strWHERE after it chops off the
final and statement as follows:

strWHERE = Left$(strWHERE, lngLen) & "; SORT BY [GroupID]"

But this causes an error rather than give me a sort. Anyone have any ideas
why this happens (or, more importantly, what I can do to fix it)? Any help
will be greeted with major thanks and rounds of applause on this end!
 
G

Guest

Nevermind. I'm a moron. I just answered my own question. Using the right
command words helps....
 

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