Add a new line with Visual Basic using Chr(10)

I have a very strange problem. I want to add a text to a memo-field in Microsoft Access 2003 using Visual Basic. I have always used Chr(10) without problems. But this time it is just overlooked!? I use DAO to get the text I want and then add Chr(10) and the new text. Should be strait forward. But the new text ends up next to the old text.  I tried copying the text into an editor and then there was a lineshift! Why does it not show in the memofield? Obviously the lineshift is there.

Thank you for all help!

Code:
    Dim vText As String, rs As DAO.Recordset, vDesc As String, SQL As String
    vText = Chr(10) & vPartnrOld & "." & vRevOld & " has been changed to " & vPartnrMod & "." & vRevMod & "-" & vRevDesc
    SQL = "SELECT tbl" & vTbl & "Changes.[Revision Description] FROM tbl" & vTbl & "Changes WHERE (((tbl" & vTbl & "Changes.Partnr)='" & vPartnrPro & "') AND ((tbl" & vTbl & "Changes.Rev)='" & vRevPro & "'));"
    Set rs = CurrentDb.OpenRecordset(SQL, dbOpenDynaset)
    If Not (rs.EOF And rs.BOF) Then
        vDesc = rs![Revision Description]
        vDesc = vDesc & LineChange & vText
        rs.Edit
        rs![Revision Description] = vDesc
        rs.Update
    End If
LVL 1
hke72Asked:
Who is Participating?
 
Haris DulicConnect With a Mentor Commented:
can you try char(13) or combination of the 10 and 13

   * Chr(10) returns a linefeed character
    * Chr(13) returns a carriage return character
    * The two-character string Chr(13) & Chr(10) returns a Windows newline
0
 
Haris DulicCommented:
i dont see anythign wrong but maybe you can try to move that Chr(10)  like below...

could you try it?


    Dim vText As String, rs As DAO.Recordset, vDesc As String, SQL As String
    vText =  vPartnrOld & "." & vRevOld & " has been changed to " & vPartnrMod & "." & vRevMod & "-" & vRevDesc
    SQL = "SELECT tbl" & vTbl & "Changes.[Revision Description] FROM tbl" & vTbl & "Changes WHERE (((tbl" & vTbl & "Changes.Partnr)='" & vPartnrPro & "') AND ((tbl" & vTbl & "Changes.Rev)='" & vRevPro & "'));"
    Set rs = CurrentDb.OpenRecordset(SQL, dbOpenDynaset)
    If Not (rs.EOF And rs.BOF) Then
        vDesc = rs![Revision Description]
        vDesc = vDesc & LineChange & Chr(10) &  vText
        rs.Edit
        rs![Revision Description] = vDesc
        rs.Update
    End If

Open in new window

0
 
hke72Author Commented:
I have already tried that. But as I said the lineshift is in the text (at least if I copy it to Word), but does not change line in my memo-textbox.
I have tried looking at the properties for the field in the form, but have not found anything.
Other ideas?
0
 
hke72Author Commented:
I also tested copying the text into Word and then copying it back. Then it was OK. There must be something about the textcoding.
Anyone?
0
 
hke72Author Commented:
Sorry, same result!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.