FoxProProgrammer
Programmer
I am working on a form that has two tabs. The data on the first tab is bound to a query that gets its data from a table, and the data on the second tab is bound to the same query, but it gets its data from two other tables. The form displays the correct data as long as the form's RecordSource contains a Query that retrieves the data from all three tables. I thought that it would be more efficient to query only the data that is needed for the tab being displayed; however, I can't get it to work.
I created two Queries named QueryTab1 and QueryTab2. One query retrieves the data for tab 1 and the other query retrieves the data for tab 2. The form's RecordSource initially contains "QueryTab1" so the correct data is displayed when the form is first opened. When the user changes the tab, I change the RecordSource with the following code:
Private Sub TabCtl0_Change()
If TabCtl0.Value = 0 then
RecordSource = "QueryTab1"
Else
RecordSource = "QueryTab2"
End If
There is some other code in the If structure but it doesn't pertain to the RecordSource. When this event procedure runs, the bound fields on the tabs don't change. Does anyone know what I am doing wrong? The Help says that Access does an automatic requery when the RecordSource changes. I thought that this meant it should update the bound fields?
Thanks in advance,
dz
I created two Queries named QueryTab1 and QueryTab2. One query retrieves the data for tab 1 and the other query retrieves the data for tab 2. The form's RecordSource initially contains "QueryTab1" so the correct data is displayed when the form is first opened. When the user changes the tab, I change the RecordSource with the following code:
Private Sub TabCtl0_Change()
If TabCtl0.Value = 0 then
RecordSource = "QueryTab1"
Else
RecordSource = "QueryTab2"
End If
There is some other code in the If structure but it doesn't pertain to the RecordSource. When this event procedure runs, the bound fields on the tabs don't change. Does anyone know what I am doing wrong? The Help says that Access does an automatic requery when the RecordSource changes. I thought that this meant it should update the bound fields?
Thanks in advance,
dz