strip space after comma

deb

Active Member
Joined
Feb 1, 2003
Messages
400
access 2010

The below takes the search word(s) delimited my a comma and searches a field.

On the below code, if the user enters a comma and space between search words, how can I strip the space, but strip the space only if it is after the comma?


Private Sub Command25_Click()
Dim strFilter As String, strFilters() As String
Dim intX As Integer

With Me
strFilters = Split(Nz(.Text23, ""), ",")
For intX = 0 To UBound(strFilters)
strFilter = strFilter & _
Replace(" OR ([EmployeeName] Like '*%F*')", _
"%F", strFilters(intX))
Next intX
.Filter = Replace(Mid(strFilter, 5), "'", Chr(34))
.FilterOn = (.Filter > "")
End With
End Sub
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Cross-posting (posting the same question in more than one forum) is not against our rules, but the method of doing so is covered by #13 of the Forum Rules. Be sure to follow & read the link at the end of the rule too!

Cross posted at: strip space if after a comma

If you do cross-post in the future and also provide a link, then there shouldn’t be a problem.
 
Upvote 0
A LIKE query with a leading wildcard would ignore leading spaces anyway.
 
Upvote 0

Forum statistics

Threads
1,221,813
Messages
6,162,117
Members
451,743
Latest member
matt3388

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top