Substitute character in field values in LibreOffice Base

Hi,

In a MEMO field, I would like to replace all occurrences of “/” with a carriage return, so it shows better in reports. Does anyone have an idea on how to proceed?

My workaround is currently to do the substitution in Writer on the resulting report.

Thanks!

R.

Hello,

You can do this with a fairly simple macro which calls a function available here → Strings (OpenOffice.org BASIC Runtime Library). The function is called Replace.

Attached is a sample with a form containing a Memo field & a push button. With the text in the memo field, click the button and the macro attached to the push button converts all / to a carriage return. The macro used to call the function is:

Option Explicit

Sub ScanText
	Dim oForm		 As Object
	Dim sMemoText	 As String
	Dim sReturn		 As String
	Dim sNewText	 As String
	oForm = ThisComponent.Drawpage.Forms.getByName("MainForm")
	sMemoText = oForm.getByName("txtMEMOTEST").Text
    sReturn = Chr(13)
    sNewText = Replace(sMemoText,"/",sReturn)
	oForm.getByName("txtMEMOTEST").Text = sNewText
	oForm.getByName("txtMEMOTEST").commit
End Sub

Both the above Sub & Function are in this sample ------ MemoFieldFix.odb