| | |
|
|
|
Excess spacing within a field |
| message from =?Utf-8?B?U0Q=?= on 13 May 2004 |
Data that was imported from another source contains spacing within the text. For example, I imported several records and many of the fields contain text such as "This is only a test". How do I remove the spaces between "is" and "only". Neither of the Trim functions (LTRIM, RTRIM,TRIM) works for this case. Any ideas on how to remove the excess spaces in the middle of the text field?
|
| Brendan Reynolds replied to =?Utf-8?B?U0Q=?= on 13 May 2004 |
Public Function RemSpace(ByVal strSource As String) As String
Dim strWork As String
strWork = Trim$(strSource)
Do While InStr(1, strWork, Space$(2)) <> 0
strWork = Replace(strWork, Space$(2), Space$(1))
Loop
RemSpace = strWork
End Function
UPDATE tblTest SET tblTest.TestText = RemSpace([TestText]);
There might be some performance benefit in replacing Space$(2) with " "
(two spaces) and Space$(1) with " " (one space). I used the Space$()
function because it's easier to see what the code is doing that way.
|
|
Archived message: Excess spacing within a field (MS Access)