ACC1x: Cannot Change the RecordSource of a Form at Run Time

ID: Q100174


The information in this article applies to:
  • Microsoft Access versions 1.0, 1.1


SYMPTOMS

You cannot change a form's RecordSource property at run time.


RESOLUTION

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:

  1. 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.


  2. Create a macro with the following action and save it as Employees2 Macro:
    
          Employees2 Macro Action
          ------------------------
             ApplyFilter
                Filter Name: Select * from Employees2;
                Where Condition: 


  3. Open the Employees form in Design view. Add a command button to the Employees form and set the OnPush property to Employees2 Macro.


  4. 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.


STATUS

This behavior no longer occurs in Microsoft Access version 2.0.


REFERENCES

Microsoft Access "User's Guide," version 1.0, pages 375-382

Additional query words: filter query requery change

Keywords : kbusage FmsProp
Version : 1.0 1.1
Platform : WINDOWS
Issue type : kbprb


Last Reviewed: March 24, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.