ACC1x: How to Use Visible Property to Simulate Property ChangesID: Q93298
|
Microsoft Access does not allow you to change some control properties, such as Color and Caption, at run time. This article discusses how you can work around this limitation.
You can work around this limitation by creating two controls that are
identical except for the property you want to change. You place these
controls at the same location with their Visible property set to No.
At the point where the property is to change, set the Visible property
of the control with the desired property setting to Yes using a Macro
SetValue action, and set the Visible property of the other control to
No in the same manner.
The following example demonstrates this method. In the example, a form
appears with one button and text box. The text box is Blue, and the
button has the Caption "Red." When you click the button, the text
box's color will change to red and the button's caption will change to
"Blue." Clicking the Blue button will toggle back to Red, and so on.
Text Box
-----------------
Control Name: Red
Fill Color: 255
Visible: No
Text Box
--------------------
Control Name: Blue
Fill Color: 16711680
Visible: Yes
Command Button
------------------------
Control Name: RedButton
Caption: Change to Red
Visible: Yes
On Push: ChangeColor.Red
Command Button
-------------------------
Control Name: BlueButton
Caption: Change to Blue
Visible: No
On Push: ChangeColor.Blue
Text Box
-------------------------
Control Name: GiveMeFocus
Width: 0
Macro Name Action Arguments
---------------------------------------------------------------
Blue GoToControl ControlName .. GiveMeFocus
SetValue Item ......... [Blue]
Expression ... [Red]
SetValue Item ......... [Blue].Visible
Expression ... True
SetValue Item ......... [Red].Visible
Expression ... False
SetValue Item ......... [RedButton].Visible
Expression ... True
SetValue Item ......... [BlueButton].Visible
Expression ... False
Red GoToControl ControlName .. GiveMeFocus
SetValue Item ......... [Red]
Expression ... [Blue]
SetValue Item ......... [Red].Visible
Expression ... True
SetValue Item ......... [Blue].Visible
Expression ... False
SetValue Item ......... [BlueButton].Visible
Expression ... True
SetValue Item ......... [RedButton].Visible
Expression ... False
For more information about changing form properties at run time, please
see the following article in the Microsoft Knowledge Base:
Q101308 ACC1x: How to Switch Form to Design Mode to Change
Properties
Additional query words: runtime read only
Keywords : kbusage FmsProp
Version : 1.0 1.1
Platform : WINDOWS
Issue type : kbhowto
Last Reviewed: March 12, 1999