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.
Might be this is a duplicate of https://bugs.documentfoundation.org/show_bug.cgi?id=143758 Have a look at the attachment there. If it describes the same behavior we will set this one as duplicate. If not: Add an example.
RobertG, I think it's the same bug, but I'm not sure. The previous bug report was focused on data not being displayed in the grid, and I'm concerned about what's in the dropdown list, but we may be talking about the same thing. I've attached an odb file that demonstrates the bug. There's a stand-alone listbox that displays the correct information and an in-grid listbox that displays the wrong information, even though they have identical ListSource properties. You can decide for yourself if this is a duplicate. BTW, I checked comboboxes today and the bug applies to them also. Because they've got the textbox component, data in the column doesn't disappear, but the data in the dropdown list is incorrect.
My apologies, I'm new to bugzilla and I only just now realized that you attached a form. Now that I've seen your form, my report is definitely a duplicate. But I also realized today that I need to use the listbox refresh method with listboxes in grids, something that isn't necessary with stand-alone listboxes. Once I add "listbox.refresh", the bug disappears. The listbox behaves exactly as I expect it to behave. *** This bug has been marked as a duplicate of bug 143758 ***