Export (0) Print
Expand All
2 out of 6 rated this helpful - Rate this topic

SetOption Method [Access 2003 VBA Language Reference]

Office 2003

The SetOption method sets the current value of an option in the Options dialog box.

expression.SetOption(OptionName, Setting)

expression Required. An expression that returns one of the objects in the Applies To list.

OptionName  Required String. The name of the option. For a list of optionname argument strings, see Set Options from Visual Basic .

Setting  Required Variant. A Variant value corresponding to the option setting. The value of the setting argument depends on the possible settings for a particular option.

Remarks

The SetOption method provides a means of changing environment options from Visual Basic code. With this method, you can set or read any option available in the Options dialog box, except for options on the Modules tab.

The available option settings depend on the type of option being set. There are three general types of options:

  • Yes/No options that can be set by selecting or clearing a check box.

  • Options that can be set by entering a string or numeric value.

  • Predefined options that can be chosen from a list box, combo box, or option group.

For options that the user sets by selecting or clearing a check box, using the SetOption method, specify True or False for the setting argument, as in the following example:

Application.SetOption "Show Status Bar", True
		

To set a type of option using the SetOption method, specify the string or numeric value that would be typed in the dialog box. The following example sets the default form template to OrderTemplate:

Application.SetOption "Form Template", "OrderTemplate"
		

For options with settings that are choices in list boxes or combo boxes, specify the option's numeric position within the list as the setting argument for the SetOption method. The following example sets the Default Field Type option to AutoNumber:

Application.SetOption "Default Field Type", 5
		

To set an option that's a member of an option group, specify the index number of the option within the group. The following example sets Selection Behavior to Fully Enclosed:

Application.SetOption "Selection Behavior", 1
		

Notes

  • When you use the SetOption method to set an option in the Options dialog box, you don't need to specify the individual tab on which the option is found.

  • You can't use the SetOption method to read or set any of the options found on the Module tab of the Options dialog box.

  • If your database may run on a version of Microsoft Access for a language other than the one in which you created it, then you must supply the arguments for the SetOption method in English.

When you quit Microsoft Access, you can reset all options to their original settings by using the SetOption method on all changed options. You may want to create public variables to store the values of the original settings. You might include code to reset options in the Close event procedure for a form, or in a custom exit procedure that the user must run to quit the application.



Applies to | Application Object

See Also | GetOption Method


Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.