I’m trying to setup an automatic filter which selects a record with a Company having the phone number which contains the typed numbers into the special field box. It works correctly but there is a problematic side effect - it gets empty.
I’ve taken the original example from the Filter from control value article and modified it adding the “lbCoPhone” control in the bottom of the form 149030246117618.odb. To try how it works enter “1” into this control then enter the “0” resulting in “10” which perfectly finds the corresponding record in “Companies” with the corresponding phone number but once you enter the non-existing numbers sequence in this field (e.g. click “2” resulting in “102”) the “lbCoPhone” control gets empty causing inconvenience required to reenter the data again (in the real use case user may wants to correct the entered number instead of entering all the sequence from the beginning again).
Can anybody suggest a workaround for this?
The filter function for the reference:
Sub FreeFilter
Dim oForm AS OBJECT
Dim stData AS String
oForm = ThisComponent.Drawpage.Forms.getByName("MainForm")
stData = oForm.getByName("lbCoPhone").Text
oForm.Filter = "( ""PHONE"" LIKE '%" & stData & "%')"
oForm.Reload()
End Sub