Getting Rid of Preceding CR/LF

dsajones

Registered User.
Local time
Today, 14:12
Joined
Jan 22, 2011
Messages
47
I have an application that looks up an address and then takes the address found and puts it in to a string field in the main table. Not quite sure what's been happening (user error the most likely) but sometimes I'm finding a CR/LF at the beginning of the field (in the database, not the lookup table). I need to leave the field editable so can't lock it down. I've tried adding a Trim function and a Ltrim function to the AfterUpdate for the field but it will only remove leading spaces, trailing spaces or trailing CR/LF. It will not remove a leading CR/LF. Any ideas?

Cheers
David
 
Check out the Replace() function. Example...
Code:
Sub Test23049857()
   Dim tmp As String
[COLOR="Green"]   'construct a string with leading vbCrLf[/COLOR]
   tmp = vbCrLf & "This " & vbCrLf & "is a test"
[COLOR="Green"]   'replace only the first vbCrLf with ""[/COLOR]
   tmp = Replace(tmp, vbCrLf, "", , 1)
End Sub
 

Users who are viewing this thread

Back
Top Bottom