Check whether first line of a memo field is empty

Ben De Vriendt

New member
Local time
Today, 12:00
Joined
Feb 10, 2015
Messages
4
Hi,

Our quotation tool, which is built in access 2003, has a memo field, which is extracted in a .txt file, to be uploaded by another system.
When the user starts the memo field with a blank line, by hitting the enter key, the upload file writes the memo field as a new line, separating it from the line indicator and thus giving errors.

My question would be:

Q: How would I determine in VBA, whether the first line of the memo field is blank

Cheers,
Ben
 
Not sure what the return key is in 2003 but I would think you can use

if left(memofield,1)=chr(12) then 'first line is blank

but you can test for the actual character required - it may be another character

You probably also want to consider if the user enters a space first as well
 
Thanks for this quick response! Google is still my friend though.
I found Chr(13) + Chr(10) in a string represent a line break, so I have solved my issue with below code:

Private Sub ReplaceLineBreaks()

Dim strMemo As String

strMemo = Me.Commentaire
strMemo = Replace(strMemo, Chr(13) & Chr(10), "")
Me.Commentaire = strMemo

End Sub
 
you can simply this code

Commentaire = Replace(Commentaire, Chr(13) & Chr(10), "")

But this will replace all Chr(13) & Chr(10) - is that what you want?
 
I wrote the subject before realizing that any line break in the text would cause the same issue.
So, indeed I want to remove all line breaks from the text.
Thanks again.
 

Users who are viewing this thread

Back
Top Bottom