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

Last reviewed: May 28, 1997
Article 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 : FmsProp kbusage
Version : 1.0 1.1
Platform : WINDOWS
Hardware : X86
Issue type : kbprb
Resolution Type : Info_Provided


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: May 28, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.