PC User
Registered User.
- Local time
- Yesterday, 16:14
- Joined
- Jul 28, 2002
- Messages
- 193
I'm trying to include sorting code in a filter code. Is this possible? Can someone help me? This is what I've made so far.
Thanks,
PC
Code:
Private Sub btnSetFilter_Click()
On Error Resume Next
Dim strSelect As String, strFrom As String
Dim strSQL As String, strWhere As String
Dim strOrderBy As String, strDirection As String
Dim intCounter As Integer, strRowSource As String
Dim strDate As String, strFilter As String
'Build SQL String *****
'Date Filter
If Not IsNull([BeginningDate]) And Not IsNull([EndingDate]) Then
If DateValue([EndingDate]) < DateValue([BeginningDate]) Then
MsgBox "The ending date must be later than the beginning date."
Else
strWhere = gstrDate & " Between #" & Me.BeginningDate & "# And #" & Me.EndingDate & "#" & " And "
End If
End If
'ComboBox Filter
For intCounter = 1 To 6
If Me("Filter" & intCounter) <> "" Then
strWhere = strWhere & "[" & Me("Filter" & intCounter).tag & "] " & " = " & Chr(34) & Me("Filter" & intCounter) & Chr(34) & " And "
End If
Next
'ComboBox Sort
strOrderBy = " ORDER BY " & Me.cboSortBy & " , " & Me.cboSortOrder
If strWhere <> "" Then
'Strip Last " And "
strWhere = Left(strWhere, (Len(strWhere) - 5))
strSQL = strWhere & strOrderBy
'Set the Filter property
strFilter = Nz(strSQL, "")
gstrFilter = Nz(strSQL, "")
Else
gstrFilter = ""
End If
End Sub
PC