Add a new line with Visual Basic using Chr(10)
Posted on 2008-11-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!
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![Revision Description] = vDesc