Senin, 29 Juni 2020

Re: [MSAccessProfessionals] Not stripping the "AND"

first i noticed "[RELTYPE]" is not on your code.

maybe used a function to strip the "AND":

..
..
    '***********************************************************************
    'Chop off the trailing " AND ", and use the string as the form's Filter.
    '***********************************************************************
    'See if the string has more than 5 characters (a trailng " AND ") to remove.
    lngLen = Len(strWhere)
    If lngLen <= 0 Then     'Nah: there was nothing in the string.
        MsgBox "No criteria", vbInformation, "Nothing to do."
    Else                    'Yep: there is something there, so remove the " AND " at the end.
        '''''''''''
        ' arnelgp
        '
        ' loop until no more " AND " at the end of string
        '
        '''''''''''
        strWhere = chopOffAnd(strWhere)
        
        'For debugging, remove the leading quote on the next line. Prints to Immediate Window (Ctrl+G).
        Debug.Print strWhere
        Me.txtCriteria = strWhere
        'Finally, apply the string as the form's Filter.
        Me.Filter = strWhere
        Me.FilterOn = True
    End If
 
End Sub



'arnelgp
Public Function chopOffAnd(ByVal s As String) As String
    With CreateObject("VBScript.RegExp")
        .Global = True
        .IgnoreCase = True
        .pattern = " AND ?$"
        s = .Replace(s, "")
    End With
    chopOffAnd = s
End Function




--
Arnelito G. Puzon


_._,_._,_

Groups.io Links:

You receive all messages sent to this group.

View/Reply Online (#115662) | Reply To Group | Reply To Sender | Mute This Topic | New Topic

Your Subscription | Contact Group Owner | Unsubscribe [sugeng.panjalu.access@blogger.com]

_._,_._,_

Tidak ada komentar:

Posting Komentar