隐藏MS Access表单上的标签,文本框和组合框

时间:2014-08-18 08:01:04

标签: ms-access-2007

我正在使用MS Access 2007。

当我点击另一个表单上的按钮时,如何隐藏表单中的标签,文本框和组合框?

以下是我已经尝试但遇到错误:应用程序定义或对象定义的错误:

Private Sub cmdAdd_Click()

Form!frmDetails!Label105.Visible = False
Form!frmDetails!Combo110_Label.Visible = False
Form!frmDetails!Combo110.Visible = False
Form!frmDetails!Label27.Visible = False
Form!frmDetails![First Name].Visible = False
Form!frmDetails![Second Name].Visible = False
Form!frmDetails!LastName.Visible = False
Form!frmDetails![ID type_Label].Visible = False
Form!frmDetails!Combo43.Visible = False
Form!frmDetails![ID No].Visible = False
Form!frmDetails!Label33.Visible = False
Form!frmDetails!Address.Visible = False
Form!frmDetails!Address2.Visible = False
Form!frmDetails!Address3.Visible = False
Form!frmDetails!Label39.Visible = False
Form!frmDetails![Contact No].Visible = False
Form!frmDetails!Label112.Visible = False
Form!frmDetails!Combo113.Visible = False
Form!frmDetails!Label113.Visible = False
Form!frmDetails!cboStatus.Visible = False
Form!frmDetails!cmdSave.Visible = False
Form!frmDetails!cmdPrint.Visible = False

End Sub

问候。

约瑟夫

1 个答案:

答案 0 :(得分:0)

所有这些控件都在您使用的按钮隐藏的同一表单上吗?如果是这样,你可以简单地使用我。controlName。可见

除此之外,您使用的是Form!formNamecontrolName。可见应有的位置,表单formNamecontrolName 。可见

Private Sub cmdAdd_Click()
    Forms!frmDetails!Label105.Visible = False
    Forms!frmDetails!Combo110_Label.Visible = False
    Forms!frmDetails!Combo110.Visible = False
    Forms!frmDetails!Label27.Visible = False
    Forms!frmDetails![First Name].Visible = False
    Forms!frmDetails![Second Name].Visible = False
    Forms!frmDetails!LastName.Visible = False
    Forms!frmDetails![ID type_Label].Visible = False
    Forms!frmDetails!Combo43.Visible = False
    Forms!frmDetails![ID No].Visible = False
    Forms!frmDetails!Label33.Visible = False
    Forms!frmDetails!Address.Visible = False
    Forms!frmDetails!Address2.Visible = False
    Forms!frmDetails!Address3.Visible = False
    Forms!frmDetails!Label39.Visible = False
    Forms!frmDetails![Contact No].Visible = False
    Forms!frmDetails!Label112.Visible = False
    Forms!frmDetails!Combo113.Visible = False
    Forms!frmDetails!Label113.Visible = False
    Forms!frmDetails!cboStatus.Visible = False
    Forms!frmDetails!cmdSave.Visible = False
    Forms!frmDetails!cmdPrint.Visible = False
End Sub