ACC2000: Changing Control Properties Affects All Records in a Form

ID: Q208961


The information in this article applies to:

Moderate: Requires basic macro, coding, and interoperability skills.


SYMPTOMS

Changing a control's property setting (such as the BackColor property setting) in a continuous form causes all instances of that control in all records to be changed.


RESOLUTION

If you want to change the control's property for the active control only, use conditional formatting.

To change the color of the active control with conditional formatting, follow these steps:

  1. Open the form in Design View.


  2. On the Format menu, click Conditional Formatting.


  3. Under Condition 1, click Field Has Focus.


  4. Change the BackColor or other properties with the formatting toolbar.



MORE INFORMATION

Microsoft Access stores a single set of property settings for each control on a form. In order for a control to appear different from record to record on a form, Microsoft Access would have to store and maintain property settings for each control for every record in the form.

If a control has approximately 50 property settings, a form with 1000 records would need to maintain 50,000 property settings. Maintaining this much information for controls would severely impact performance.

Steps to Reproduce Behavior

  1. Open the sample database Northwind.mdb.


  2. Create the following new macro and save the macro as Highlight:


  3. 
       Macro Name   Action     Comment
       --------------------------------------------------
       On           SetValue   Change BackColor to Yellow
       Off          SetValue   Change BackColor to White
    
       Highlight Actions
       ---------------------------------------------
       SetValue
          Item: [Screen].[ActiveControl].[BackColor]
          Expression: 8454143
       SetValue
          Item: [Screen].[ActiveControl].[BackColor]
          Expression: 16777215 
  4. Create a new form based on the Customers table. Add three or four fields from the table to the form. Make sure the form's DefaultView property is set to Continuous Forms.


  5. On the View menu, click Tab Order. Note the name of the first control listed, and then close the dialog box. Set the following properties for every text box control on the form except the first control listed in the Tab Order dialog box:


  6. 
       OnEnter: Highlight.On
       OnExit: Highlight.Off 
  7. Save the form as Test.


  8. View the form in Form view. Use the TAB key to move from control to control on the form. Note that as you move from control to control, the BackColor property for all controls, not just the active control, is changed.



REFERENCES

For more information about the format property, click Microsoft Access Help on the Help menu, type "Format Property" in the Office Assistant or the Answer Wizard, and then click Search to view the topic.

Additional query words: prb


Keywords          : kbusage kbdta FmsProp 
Version           : WINDOWS:2000
Platform          : WINDOWS 
Issue type        : kbprb 

Last Reviewed: May 13, 1999