Function to add hard returns to my fields

I

ID10Terror

Hi:

I am parsing some text that I receive thru emails (pairs) (city:
somehwere). Everything works except that I need a hard return added to the
field if the text is looooong (as in memo length). For some reason it will
not work. After I manually enter hard carriage returns in that field and
enter something (X), the parsing works fine. Can anyone help me with a
function that will go thru all the records of a certain field (fldMemo1).
make a hard return (ctrl + enter) add the letter X.

Thanks You


info:

Function ParseTextLinePair(strSource As String, strLabel As String)
Dim intLocLabel As Integer
Dim intLocCRLF As Integer
Dim intLenLabel As Integer
Dim strText As String

' locate the label in the source text
intLocLabel = InStr(strSource, strLabel)
intLenLabel = Len(strLabel)
If intLocLabel > 0 Then
intLocCRLF = InStr(intLocLabel, strSource, vbCrLf)
If intLocCRLF > 0 Then
intLocLabel = intLocLabel + intLenLabel
strText = Mid(strSource, _
intLocLabel, _
intLocCRLF - intLocLabel)
Else
intLocLabel = Mid(strSource, intLocLabel + intLenLabel)
End If
End If
ParseTextLinePair = Trim(strText)
End Function
 
K

Ken Snell [MVP]

You don't say what you've tried, but adding a "hard return" (the combination
of Chr(13) and Chr(10)) to a field's contents is fairly easy to do. You just
need to decide where in the text string the hard return is to be entered.
For example, if you know it should go after the 150th character:

If Len(MyFieldValue) > 150 Then _
MyFieldValue = Left(MyFieldValue, 150) & vbCrLf & _
Mid(MyFieldValue, 151)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top