Microsoft KB Archive/100174
ACC1x: Cannot Change the RecordSource of a Form at Run Time
The information in this article applies to:
- Microsoft Access versions 1.0, 1.1
You cannot change a form's RecordSource property at run time.
Although you cannot change the actual RecordSource property of a form, you can use the Apply Filter macro action to simulate the effect.
The following steps demonstrate the method to simulate changing the RecordSource:
- Open the sample database NWIND.MDB. Make a copy of the Employees table and save it as Employees2. Delete five records from the Employees2 table.
Create a macro with the following action and save it as Employees2 Macro:
Employees2 Macro Action ------------------------ ApplyFilter Filter Name: Select * from Employees2; Where Condition:
- Open the Employees form in Design view. Add a command button to the Employees form and set the OnPush property to Employees2 Macro.
- Open the form in Form view and go to the last record of the form. Note how many records are in the Employees field. Next, choose the command button and go to the last record of the form. Note that there are now five fewer records in the form.
NOTE: If you apply this method to your own tables and the tables do not have the same fields, you must set the Visible property of the invalid controls to No to prevent #Name? errors.
This behavior no longer occurs in Microsoft Access version 2.0.
Microsoft Access "User's Guide," version 1.0, pages 375-382
Additional query words: filter query requery change
Keywords : kbusage
Issue type : kbprb
Last Reviewed: November 4, 2000