I have a main form called "frmqryMainSort" and a subform called, "frmqryMainSortSubform". There are two tabs on the main form. The subform was placed on the first tab. Then a copy of the same subform (copy/pasted) was placed on the second tab. I want them to be the same exact subforms.
The subform's record source is set to a query called, "qryMainSort". I want that to be the default recordsource when the user opens up the main form with subform. Since, the first tab is displayed by default when opened, and I want the first tab to have the "qryMainSort" records.
Now, depending on which tab is chosen, I want the recordsource to change on the subform. Here is the code I have on the "On Change" event of the tab control:
Code:
If MainSortTab.Value = 0 Then
Me.frmqryMainSortSubform.Form.RecordSource = "qryMainSort"
ElseIf MainSortTab.Value = 1 Then
Me.frmqryMainSortSubform.Form.RecordSource = "qryMainSortPTI"
End If
Now here's the weird behavior..
If I set the subform's recordsource to be "qryMainSortPTI" by default (instead of "qryMainSort") in the properties tab of the subform, everything works fine. When I choose the different tabs, the recordsource changes as desired. However, the problem is that I want the default recordsource to be the other query, "qryMainSort" when the user opens up the form.
If I set the subform's recordsource to be "qryMainSort" by default in the properties tab of the subform, the recordsource won't change when I move from tab to tab. When I click on the second tab, the source looks like "qryMainSort" (which is wrong). When I click on the first tab, it flashes the "qryMainSortPTI" records, then changes real fast to the "qryMainSort" records. So I am essentially getting the "qryMainSort" records on both tabs.
Why does it work if I set the default recordsource to be one over the other? Help!!! Thanks!