Application.SetOption 方法 (Access)Application.SetOption method (Access)

SetOption 方法設定 [ Access 選項] 對話方塊中選項的目前值。The SetOption method sets the current value of an option in the Access Options dialog box.

語法Syntax

運算式SetOption(OptionName設定)expression.SetOption (OptionName, Setting)

expression 代表 Application 物件的變數。expression A variable that represents an Application object.

參數Parameters

名稱Name 必要/選用Required/Optional 資料類型Data type 描述Description
OptionNameOptionName 必要Required StringString 選項的名稱。The name of the option. 選項名稱引數字串清單,請參閱設定 Visual Basic 中的選項For a list of option name argument strings, see Set options from Visual Basic.
SettingSetting 必要Required VariantVariant 對應至選項設定的值。A value corresponding to the option setting. setting 引數的值取決於特定選項可能的設定值。The value of the setting argument depends on the possible settings for a particular option.

註解Remarks

可用的選項設定值取決於設定的選項類型。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.

對於使用者來設定選取或清除核取方塊,使用SetOption方法的選項,指定 setting 引數,如下列範例所示 ,則為 TrueFalseFor 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

若要設定一種選項使用SetOption方法,指定的字串或 [對話方塊] 方塊中輸入的數值。To set a type of option by using the SetOption method, specify the string or numeric value that would be typed in the dialog box. 下列範例會將預設表單範本設定 OrderTemplate。The following example sets the default form template to OrderTemplate.

Application.SetOption "Form Template", "OrderTemplate"

針對 [選項] 設定所選擇清單方塊或下拉式方塊中的,指定選項] 清單中的數值位置以 SetOption 方法的引數的設定。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

注意

當您結束 Microsoft Access 時,您可以使用重設所有選項其原始設定 SetOption 方法上所有已變更的選項。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. 您可能會包含程式碼來重設表單的Close事件程序或自訂結束程序的使用者必須執行來結束應用程式中的選項。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.

支援和意見反應Support and feedback

有關於 Office VBA 或這份文件的問題或意見反應嗎?Have questions or feedback about Office VBA or this documentation? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.