filter combo (1 Viewer)

ClaraBarton

Registered User.
Local time
Today, 01:11
Joined
Oct 14, 2019
Messages
789
@MajP I'm struggling with the GetSQL_Filter. Everything was working well until I added in the filter combos. I've tried to work through the function but everytime I edit it I create a mess.

I get this with the below code: (fAmount and fMemo are filter combos)
1767314700870.png

I want this:
1767314486494.png

Code:
If Nz(Me.SAmount, 0) <> 0 Then
    strAmount = GetSQL_Filter(FAmount, "tblTransactions.Amount = " & Me.SAmount & "" & AndOr)
End If
If Not Trim(SAccount & " ") = "" Then
    strAccount = "AccountID = " & Me.SAccount.Value & "" & AndOr
End If
If Not Trim(SMemo & " ") = "" Then
    strMemo = GetSQL_Filter(FMemo, "CombMemo = '" & Me.SMemo & "'" & AndOr)
End If
If Not Trim(SName & " ") = "" Then
    strName = "FullName = '" & Me.SName & "'" & AndOr
End If
If Not Trim(SDate & " ") = "" Then
    strDate = GetDateRange("CkDate", SDate.Value)
End If

Code:
Public Function GetSQL_Filter(TheFilterType As FilterType, ByVal val As String, Optional ByVal val2 As String = "") As String
  Dim GSF As String
  Select Case TheFilterType
    Case flt_Equal
     GSF = " = " & val
    Case flt_LikeFromBeginning 'Text*
      If Left(val, 1) = "'" Then
        val = "'*" & MID(val, 2)
      Else
        val = "'*" & val & "'"
      End If
      GSF = "Like " & val
    Case flt_LikeAnywhere  '*test*'
      If Left(val, 1) = "'" Then
        val = "'*" & MID(val, 2)
        val = Left(val, Len(val) - 1) & "*'"
      Else
        val = "'*" & val & "*'"
      End If
      GSF = "Like " & val
    Case flt_LikeFromEnd 'Text*
     If Left(val, 1) = "'" Then
        val = Left(val, Len(val) - 1)
        val = val & "*'"
      Else
        val = "'*" & val & "*'"
      End If
      GSF = "Like " & val
    Case flt_GreaterThan
      GSF = " > " & val
    Case flt_GreaterThanOrEqual
      GSF = " >= " & val
    Case flt_lessThan
      GSF = " < " & val
    Case flt_LessThanOrEqual
      GSF = " <= " & val
    Case flt_Between
      If val2 <> "" Then
        GSF = "BETWEEN " & val & " AND " & val2
      End If
  End Select
    GetSQL_Filter = GSF
End Function
 

Attachments

  • 1767314032090.png
    1767314032090.png
    20.3 KB · Views: 10
Last edited:
I’m not sure about all the code but the filter displayed in the text box has the chkDate between the higher value and lower value. This should be reversed.
 

Users who are viewing this thread

Back
Top Bottom