Results 1 to 2 of 2
  1. #1
    2 Star Lounger
    Join Date
    Jun 2002
    Posts
    114
    Thanks
    0
    Thanked 0 Times in 0 Posts

    visibility on current (Access 2000)

    In my code written below the following lables and controls remain always invisible even though my control MyCustomer is false:

    Me!LblTurnDown.Visible = False
    Me!TurnDown.Visible = False
    Me!CmdConvert.Visible = False

    My code is :


    Dim ctr As Control
    If Me![MyCustomer] = True Then
    Me!LblMyCustomer.Visible = True
    Me!LblTurnDown.Visible = False
    Me!TurnDown.Visible = False
    Me!CmdConvert.Visible = False
    For Each ctr In Me.Controls
    If ctr.Tag = "Hide" Then ctr.Enabled = False
    Next ctr
    Else
    For Each ctr In Me.Controls
    If ctr.Tag = "Hide" Then ctr.Enabled = True
    Next ctr
    Me!LblMyCustomer.Visible = False
    End If

    Frankly, i have copied the above code and i do not understand it quite well.
    Shall i write the word Hide in the Tag propert of the control?

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: visibility on current (Access 2000)

    Well, I understand it but I still don't know what it's trying to do. this code ...

    For Each ctr In Me.Controls
    If ctr.Tag = "Hide" Then ctr.Enabled = False
    Next ctr
    Else
    For Each ctr In Me.Controls
    If ctr.Tag ="Hide" Then ctr.Enabled = True
    Next ctr

    confuses me. It says, essentually, for each control in the form, if the tag says "hide", then disable the control, otherwise, for each control in the form, if the tag says "hide", then enable the control! I suspect that it should read like this if the intent is to disable all controls with "hide" in the tag and enable the rest:

    <code>For Each ctr In Me.Controls
    If ctr.Tag = "Hide" Then ctr.Enabled = False
    Else
    If ctr.Tag <>"Hide" Then ctr.Enabled = True
    Next ctr</code>


    Enabled has no effect on the visiblity of a control and I don't see you setting the controls' visibility to true anywhere, only to false.

    Please note that you also should be checking for the TypeOf ctr or for ctr.ControlType, since not all controls have an enabled property and trying to enable one that doesn't will cause an error.
    Charlotte

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •