我正在尝试将访问模块设置为变量,以便可以使用变量名而不是实际模块名来调用某些函数。这将节省我很多时间来更改表单中被调用模块的名称。
我尝试添加一个公共变量'Mod_ActiveModule',如下所示:
Public Str_FormLevel_01 As String
Public Str_FormLevel_02 As String
Public Str_FormLevel_03 As String
Public frm_FormLevel_01 As Form
Public frm_FormLevel_02 As Form
Public frm_FormLevel_03 As Form
Public Mod_ActiveModule As Module
下面显示的是我认为会将“ Mod_ActiveModule”设置为名为“ Mod_Batches_DP_Pack”的模块的Sub-但它不起作用!!
Private Sub cmd_Options_Click()
On Error GoTo ErrorHandler
Str_FormLevel_01 = "frm_Batches_04_DP_Pack"
Str_FormLevel_02 = "frm_Batches_04_DP_Pack_Edit"
Str_FormLevel_03 = "frm_Batches_04_DP_Pack_Edit_Detail"
Set frm_FormLevel_01 = Form_frm_Batches_04_DP_Pack
Set frm_FormLevel_02 = Form_frm_Batches_04_DP_Pack_Edit
Set frm_FormLevel_03 = Form_frm_Batches_04_DP_Pack_Edit_Detail
Set Mod_ActiveModule = Mod_Batches_DP_Pack
Call ActiveModule.SetUpContextMenu_Level_01
CommandBars("MenuOptions").ShowPopup
ExitHandler:
Exit Sub
ErrorHandler:
Debug.Print "Error: " & Err.Number & ": " & Err.Description
Debug.Print "Error On: " & Form.Name & " - cmd_Options_Click"
Resume ExitHandler
End Sub
这里的任何帮助将不胜感激