CodexBloom - Programming Q&A Platform

MS Access: implementing Form Filter optimization guide After Updating Records

๐Ÿ‘€ Views: 82 ๐Ÿ’ฌ Answers: 1 ๐Ÿ“… Created: 2025-07-17
ms-access vba form-filter

I'm converting an old project and I need some guidance on I just started working with I'm working with a frustrating scenario in MS Access 2019 where the filter applied to a form does not seem to work after I update records via a subform. The main form displays a list of customers, and the subform allows entering orders for the selected customer. When I change the status of an order in the subform and the focus returns to the main form, I expect the filter to refresh accordingly to only show customers with active orders. Hereโ€™s the relevant part of my VBA code that updates the order status: ```vba Private Sub btnUpdateStatus_Click() Dim db As DAO.Database Dim rs As DAO.Recordset Set db = CurrentDb() Set rs = db.OpenRecordset("SELECT * FROM Orders WHERE OrderID = " & Me.OrderID) If Not rs.EOF Then rs.Edit rs!Status = Me.cmbStatus rs.Update End If rs.Close Set rs = Nothing ' Call refresh on the main form to apply the filter Me.Parent.Requery End Sub ``` The filter is set in the main form's `On Load` event like this: ```vba Private Sub Form_Load() Me.Filter = "Status = 'Active'" Me.FilterOn = True End Sub ``` However, after the update, the filter does not reflect the new status from the subform. I checked that the subform correctly updates the records, but the filter on the main form remains exploring. Iโ€™ve also tried using `Me.Refresh` instead of `Me.Parent.Requery`, but it yielded the same outcome. Is there a specific reason why the filter isnโ€™t updating as expected? Iโ€™ve also made sure that the `OrderID` in the subform is correctly linked to the main form's customer. Any insights into what might be going wrong here would be greatly appreciated. This issue appeared after updating to Vba 3.9. Any help would be greatly appreciated! What's the best practice here? I'm working with Vba in a Docker container on Debian. Is this even possible? Any suggestions would be helpful.