更新事件后无法在MS Access中切换标签可见性 [英] Unable to toggle labels visibility in MS Access after update event

查看:70
本文介绍了更新事件后无法在MS Access中切换标签可见性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前有一个更新后事件,该事件会循环浏览表单中的文本框,并在其编号是否低于某个阈值时切换其可见性.

I currently have a an after update event that cycles through the textboxes in a form and toggles their visibility on if they are numbered below a certain threshold number.

Dim i As Long    
        Dim iMin As Long    
        Dim iMax As Long    
        iMin = 1   
        iMax = Me.txtMeasure.Value   
        With Me   
            For i = iMin To iMax   
                              .Controls("V" & i).Visible = True   
            Next i   
        End With

这些文本框被命名为V1, V2, V3...V110,等等."而与每个文本框相对应的标签被标记为lblV1lblV2lblV3lblV110等."默认情况下,文本框和标签为不可见,而更新后事件将其可见性打开.该代码适用于文本框,但不适用于标签.我注意到,虽然标签不可见,但切换到设计视图,然后又返回到窗体视图,标签突然看起来可见.有没有一种方法可以调试它们,使它们同时可见?

The textboxes are named V1, V2, V3...V110, etc." while the labels corresponding to each textbox are labeled lblV1, lblV2, lblV3, lblV110, etc." The textboxes and labels are defaulted to be invisible while the after update event toggles their visibility on. The code works for the textboxes but fails to work for the labels. I have noticed that the while the labels don't appear visible, switching to design view and then back to form view, the labels suddenly appear visible. Is there a way to debug this so that they both appear visible at the same time?

推荐答案

尝试一下,它循环遍历控件,如果它是textboxlabel,则您可以对它们进行操作,我将它们设置为Visible在此代码中.

Try this , it loops through controls and if it is a textbox or label you can do what you want with them, I have set them to Visible in this code.

Dim con As Control
Dim i As Long
Dim iMin As Long
Dim iMax As Long
Dim textBoxArr
Dim j As Long
        iMin = 1
        iMax = Me.txtMeasure.Value
     textBoxArr = Array("V1", "V2", "V3", "V4", "V5", "V6", "V7")
    For Each con In Me.Controls    
        If TypeName(con) = "TextBox" Or TypeName(con) = "Label" Then
          For j = 0 To UBound(textBoxArr)
            If con.Name = textBoxArr(j) Or con.Name = "lbl" & textBoxArr(j) Then
                con.Visible = True: Exit For
            End If
          Next j
        End If
    Next con

这篇关于更新事件后无法在MS Access中切换标签可见性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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