https://bugs.documentfoundation.org/show_bug.cgi?id=166304
Bug ID: 166304
Summary: Listbox in grid control displays results from previous
SQL ListSource property.
Product: LibreOffice
Version: 24.8.6.2 release
Hardware: All
OS: Windows (All)
Status: UNCONFIRMED
Severity: normal
Priority: medium
Component: Base
Assignee: [email protected]
Reporter: [email protected]
Overview:
When the SQL ListSource of a listbox on a grid control is updated by a macro,
it displays the results from the previous ListSource, not the current
ListSource.
Steps to Reproduce:
Standard form/subform setup with a foreign key in the subform referring to a
primary key in the main form. Data in the 2 forms are displayed in grid
controls.
The subform has a ParentID column containing the ID of another row in the
subform. The grid control uses a listbox for that column. The listbox displays
all the IDs that are candidates for the ParentID value, i.e. the IDs of all the
other rows in the subform.
When the user clicks on a different row in the main form, the data in the
subform changes and the ListSource (SQL) property of the listbox has to be
updated so that it will display the new candidate ParentIDs, i.e. the IDs from
the new recordset. This is done with a macro triggered by the subform's When
Reloading event.
Sub mcrUpdateLstParentID
REM Runs in the fsfr's When Reloading event. A weird bug causes
REM the lst to show the results of the previous ListSource, not the current
one.
REM Currently running in the Mouse Button Pressed event, but still weird bug.
Dim objFrm As Object
Dim objFsfr As Object
Dim objGrd As Object
Dim objLstParentID As Object
Dim strSqlSelect(0) As String
'Main frm
objFrm = ThisComponent.DrawPage.Forms.getByName("frmProviders")
'Subfrm
objFsfr = objFrm.getByName("fsfrProviderAddress")
'If the main frm's on the insert row then there's no ProviderID value.
'Identifying the insert row:
'If the frm has no records, frm.Row = 1 but frm.isFirst = False.
'If the frm has >= 1 records, row 0 is the insert row.
If (objFrm.Row = 1 And Not objFrm.isFirst) Or objFrm.Row = 0 Then
'Since the new provider isn't in the database yet, there are
'also no address parts in the database.
strSqlSelect(0) = "Select NULL FROM ""tblProviderAddresses"""
Else
strSqlSelect(0) = "Select ""ID"" FROM ""tblProviderAddresses""
WHERE ""ProviderID"" = " & objFrm.getString(micClmID)
End If
objGrd = objFsfr.getByName( GridNameArray(objFsfr)(0) )
objLstParentID = objGrd.getByName("lstParentID")
objLstParentID.ListSource = strSqlSelect
End Sub
Actual Results:
The listbox doesn't display the results of the current SQL statement in the
ListSource property. It displays the results from the previous ListSource
property, i.e. the IDs from the previous recordset. I inserted a MsgBox to
display the ListSource after it was updated, and it showed the correct SQL
statement.
If the macro is reassigned to the listbox's Mouse Button Pressed event, it can
often be coaxed into displaying the correct IDs by clicking on another row and
then clicking on the row you want. But this works inconsistently and is
confusing to the user.
Expected Results:
Display the results from the current SQL ListSource property.
Build Date & Hardware:
Windows 10 Version 22H2 (OS Build 19045.5737)
Additional Information:
LO 24.8.6.2
FWIW, I have a work-around with the grid used only to display data and a
stand-alone listbox used to insert the ID values. The stand-alone listbox
displays the correct values, so the bug affects only listboxes on grids.
--
You are receiving this mail because:
You are the assignee for the bug.