ACC1x: How to Switch Form to Design Mode to Change PropertiesID: Q101308
|
There are a number of form properties in Microsoft Access that cannot be changed while the form is active. To work around this limitation, you can use a macro to change the form into Design view, use SetValue actions to change any property, and then change the form back to Datasheet view.
You can change the form into Design view by using a DoMenuItem macro
action as shown below:
MacroName Action
----------------------
Test1 DoMenuItem
Test1 Actions
-----------------------
DoMenuItem
Menu Bar: Form
Menu Name: View
Command: Form Design
MacroName Action
----------------------
Test1 DoMenuItem
Echo
Test2 DoMenuItem
Echo
Test1 Actions
-----------------------
DoMenuItem
Menu Bar: Form
Menu Name: View
Command: Form Design
Echo
Echo On: No
Test2 Actions
------------------
DoMenuItem
Menu Bar: Form
Menu Name: View
Command: Browse
Echo
Echo On: Yes
Form
--------------------------------
Form: Form1
Caption: Form1
ControlSource: Categories
OnClose: Macro1.Onclose
Textbox: text box1
ControlName: Category ID
ControlSource: Category ID
Textbox: text box2
ControlName: Category Name
ControlSource: Category Name
command button: Button1
Caption: Filter
OnPush: =ChangeFilter()
command button: Button2
Caption: Close
OnPush: =Macro1.Close
MacroName Action Defined Below
-------------------------------------------
OnClose SetWarnings 1
Close Close 2
1. OnClose Action
-------------------
Warnings On: No
2. Close Action
----------------------
Object Type: Form
Object Name: Form1
Function ChangeFilter ()
DoCmd Echo False
DoCmd DoMenuItem 0, 2, 0, 0
Forms!Form1.AllowFilters = Not Forms!Form1.AllowFilters
DoCmd DoMenuItem 0, 2, 1, 0
DoCmd Echo True
End Function
NOTE: For development work, you may want to comment out the DoCmd
Echo actions.
For more information about changing control properties at run time, please
see the following article in the Microsoft Knowledge Base:
Q93298 ACC1x: How to Use Visible Property to Simulate Property
Changes
Additional query words: flip switch browse mode runtime run time read only
Keywords : kbusage FmsProp
Version : 1.0 1.1
Platform : WINDOWS
Issue type : kbhowto
Last Reviewed: May 19, 1999