So my problem here is something I cannot find a work around to. I have plenty of forms setup in the same way with subtle differences, but there is a common problem in all of them.
Each form has at least two subform tabs in them. Each subform is displayed in Datasheet view. One is made for daily inspection sign offs and the other for daily inventory sign offs. Each datasheet view has entries for all days of the current month. For those who sign-off daily there are no issues, but for supervisory staff I am coming across a problem
Supervisory staff are allowed to look at previous months if necessary. You type in the month and year into text boxes and click a button that will run the desired month and year within the where statement to pull up the desired results for both inspection and inventory sheets.
The code for the button looks something like this.
Form_subForm_UnitInventory.Form.RecordSource = "SELECT * FROM tbl_Inventory " & A1Filter
Form_subForm_UnitInventory.Form.Requery
Form_subForm_UnitInspection.Form.RecordSource = "SELECT * FROM tbl_Inspection " & A1Filter
Form_subForm_UnitInspection.Form.Requery
The A1Filter has an if statement that runs the different month and year if it is placed within the text boxes.
The form on load is tabbed on the inspection datasheetview for the subform. When running the code while the inspection tab is open the datasheet requeries properly with the desired month and year for review. When I tab over to the inventory tab it will show the desired month and year correctly as well, but when I attempt to requery on the inventory sheet it will not requery correctly. No matter how many times I requery nothing happens.
If I were to on load tab over to the inventory tab and run the code while the inventory datasheet is open then it will requery correctly... but now the inspection tab will not requery correctly. I was thinking that it had something to do with my code, but now I think it is something with the way Access handles datasheet view for subforms, because If have omitted both recordsource and requery for either inspection or inventory and tested it the same issue occurs. I found a weird way to 'reset' the problem and here it is.
If I requery with the inspection tab open, to make the inventory tab work I must:
1. goto inventory tab
2. go back to inspection tab
3. go back again to inventory tab and then run the code.
This works 100% of the time. Vice Versa if I run the requery first on inventory tab I must do the 3 tab switch to make inspection tab work.
I feel like requery doesnt work correctly when you run the requery on one subform datasheet view and change to the other. Is there anyway I can alleviate this problem?