Forum Discussion
VBA_Coder
Jan 13, 2023Copper Contributor
Access 2019 - List Box.Requery event on Main Form causes Sub Form Current event to trigger
I have a simple Main Form with one SubForm. On the Main Form I have a ListBox called "listItems" whose RowSource is set to a Query. If I issue a listItems.Requery, the Current event of the SubForm ...
arnel_gp
Jan 15, 2023Iron Contributor
just maybe there is a Parent/Child Link fields on the subform and the Parent Link is the Listbox?
you can also use another subform, instead of listbox.
use Parent/Child Linke field on the "New" subform.
you may need to add an Unbound textbox to the main form.
the control source of the Unbound textbox is the PK field of the "old" subform:
=[subformname].Form![thePKField]
now add Parent/Child link fields to the "New" (the substitute to your listbox) subform.
the Parent will be the Unbound textbox and the child is the FK field.
so you do not requery the "new" subform. it get re-queried auto.
you can also use another subform, instead of listbox.
use Parent/Child Linke field on the "New" subform.
you may need to add an Unbound textbox to the main form.
the control source of the Unbound textbox is the PK field of the "old" subform:
=[subformname].Form![thePKField]
now add Parent/Child link fields to the "New" (the substitute to your listbox) subform.
the Parent will be the Unbound textbox and the child is the FK field.
so you do not requery the "new" subform. it get re-queried auto.
VBA_Coder
Jan 17, 2023Copper Contributor
There is no "Parent/Child Link" based on the listbox, other than the query that is the RecordSource for the ListBox has a WHERE clause that has the ScheduleID set to the "ScheduleID" in the Current Record of the subform. I have been tinkering with putting hidden text boxes on the Main Form so when the user clicks a row of Appointments in the Subform, I would store the CurrentRecord number as well as the ScheduleID in these hidden fields so that I could somehow move the SubForm back to the row/record that is in the hidden field as well as change my Query's WHERE clause that is used for the ListBox to use that hidden text box that has the ScheduleID. I still don't have an elegant solution at this time, but I'm getting closer....
- VBA_CoderJan 28, 2023Copper ContributorThis behavior of requerying a listbox on the Main Form, causing SubForm's to reload, is causing a lot of coding issues because the Current event of the SubForm is triggering causing complexity in how I have to handle the code I want to happen in the SubForm, not when I simply want a listbox on the Main Form to requery to update it's list items