error_prone
asked on
String Extraction Memo Field
Is there a way to get the first 2 lines of a memo field? The lines would be split by a hard return.
ASKER
This just gives me a number and not the string on the first and second lines.
Try this: memo field: rt
Private Sub Command8_Click()
Dim s As String ' string to hold memo text
s = Me.rt 'memo field
Dim x As Variant ' array to hold lines of text
x = Split(s, Chr(13) & Chr(10))
Dim l1 As String 'line 1
Dim l2 As String
l1 = Replace(x(0), Chr(13) & Chr(10), "")
l2 = Replace(x(1), Chr(13) & Chr(10), "")
End Sub
Private Sub Command8_Click()
Dim s As String ' string to hold memo text
s = Me.rt 'memo field
Dim x As Variant ' array to hold lines of text
x = Split(s, Chr(13) & Chr(10))
Dim l1 As String 'line 1
Dim l2 As String
l1 = Replace(x(0), Chr(13) & Chr(10), "")
l2 = Replace(x(1), Chr(13) & Chr(10), "")
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Actually need to use it in a query...
play with chr(10) and see the effect on the second line.
hnasr,
Your apporach will throw an error if there is only one line in the memo column.
:)
Patrick
Your apporach will throw an error if there is only one line in the memo column.
:)
Patrick
ASKER
matthewspatrick - That works!
error_prone,
Glad to help! If you have not already done so, I would really appreciate it if you could please return to my article
https://www.experts-exchange.com/Programming/Languages/Visual_Basic/A_1336-Using-Regular-Expressions-in-Visual-Basic-for-Applications-and-Visual-Basic-6.html
and click 'Yes' for the 'Was this helpful?' voting.
Patrick
Glad to help! If you have not already done so, I would really appreciate it if you could please return to my article
https://www.experts-exchange.com/Programming/Languages/Visual_Basic/A_1336-Using-Regular-Expressions-in-Visual-Basic-for-Applications-and-Visual-Basic-6.html
and click 'Yes' for the 'Was this helpful?' voting.
Patrick
InStr(1,[YourMemoField], Chr(13))
HTH,
Daniel