Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

RecordSource Property Problem

Status
Not open for further replies.

FoxProProgrammer

Programmer
Apr 26, 2002
967
US
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
 
FoxProProgrammer,

Try:

If TabCtl0.Value = 0 then
RecordSource = "QueryTab1"
Else
RecordSource = "QueryTab2"
End If
Me.Requery
 
Thanks for your reply, thekon. I found the error and now it works. Of course I did something dumb! The problem was in the WHERE clause of QueryTab1 and QueryTab2. Thanks again!

dz
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top