0
votes

I have a main form contains two sub forms created in MS Access. There are two text boxes on the main form. After the user enters the start and end dates in the text boxes, and clicks on the search button, the information in these two sub forms should be recalculated and refreshed the results on the sub forms and showed within the main form.

Once, I changed the data source for one sub form and saved it, I don’t know whether it caused the problem. Now, after the user enters the dates, and search the result, one of the sub form opens by itself first with correct result. After the user closes this sub form, the main form with two sub forms display with the correct results.

How can I stop the first sub form popping up first, just show main form with two sub forms together?

Thank you for your help!

1
delete the data source for the sub form. - ashleedawg
A data source does not open a form. You must have changed the code of the search buton. - Wolfgang Kais
Show the code behind the search button to get good answer. - Tarun. P
Thanks for your reply. I checked on the popping open result again, accurately, it is the result of a query1 which I changed once before to replace the original sub form record source, not the sub form itself popping open. Now I use a new query2 for this sub form's record source. I didn't change any code for search button. In some reason, the program always remembers the query1and popping up after clicking the search button before the main form with the sub forms show even through the current record source for this sub form is query2. How can I stop this popping up query1 to show? Many thanks! - Jane

1 Answers

0
votes

Subform always opens before the main form, see below for form events order. To avoid subform popping up first, you can set the subform recordsource as null on form load.

Order of events for database objects

enter image description here