在“访问"表单上将控件分组在一起 [英] Grouping controls together on an Access form

查看:103
本文介绍了在“访问"表单上将控件分组在一起的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Access2003表单,我想通过VBA代码将多个控件组合在一起并以编程方式更改可见性.

I have an Access2003 form where I wanted to group several controls together and change visibility programatically, though VBA code.

这可能吗?我知道我可以通过Format-> Group对项目进行分组,但是如果这样做,如何在代码中引用整个组?

Is this possible? I do know that I can group items through Format -> Group, but if I do that, how do I refer the the entire group in my code?

谢谢

推荐答案

您可以将所有控件放在组框控件中,然后更改组框本身的可见性.

You could place all the controls in a group box control then change the visibility of the group box itself.

您还可以在要分组的每个控件的tag属性中添加一个值,然后在VBA中循环遍历该控件并检查该值并在那里更改可见性.

You could also add a value in the tag property of each control you want to group, then in VBA loop through the control and check for that value and change the visibility there.

将要分组的所有控件的tag属性设置为groupABC之类的内容.

Set the tag property of all the controls you want to group to something like groupABC or whatever you wish.

然后在代码中的某处使用它循环遍历表单控件并进行检查.

Then somewhere in your code use this to loop through the form controls and check for it.

Dim ctrl As Control
For Each ctrl In Me.Controls
    If ctrl.Tag = "groupABC" Then
        ctrl.Visible = False
    End If
Next

这篇关于在“访问"表单上将控件分组在一起的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆