Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!

How to hide all other buttons/labels on a form?

Discussion in 'Information Technology' started by Adnan, Jul 28, 2006.

  1. Adnan

    Adnan
    Expand Collapse
    Guest

    Halloo Fellows,
    My frmMain is large with lots of button, It looks (designed) like a wab page
    and has a lot of button all over the place, the question is, when I click on
    a button or label a want to display just four or five of these buttons and
    hide all the rests, I can do it by:
    Me.cmd1.Visible = True
    Me.Label1.Visible = True
    Me.cmd2.Visible = False
    Me.Label2.Visible = False
    etc…

    but the code gets extremely long and it confuses me sometimes. Therefore, I
    was wondering if there is a Module code, which I would then call it with just
    a line of code instead of typing long codes for each button.

    Thank you very much for any help provided,
    Adnan, Computer Science Student.

    --
    Please post all your inquiries on this community so we can all benefit -
    Thank you!
     
  2. Loading...

    Similar Threads Forum Date
    World War 1 To show their contempt for death, some Sikhs had refused to hide in the trenches History of Sikhism May 14, 2014
    Opinion Underneath The Turban: Why Sikhs Do Not Hide Breaking News Aug 23, 2012
    Opinion Underneath the Turban: Why Sikhs Do Not Hide? Breaking News Aug 13, 2012
    UK Hideously diverse Britain: What makes a Sikh join the far right? (Editorial) Breaking News Jun 17, 2010
    Politics Stephen Harper's Canada Chided For Cowardice (Sikh Chic) Breaking News Jun 6, 2010

  3. Allen Browne

    Allen Browne
    Expand Collapse
    Guest

    If you hide a control that has a button attached, that attached label will
    hide as well, i.e. you don't need to set the Visible property of an attached
    label.

    You can certainly create a function that sets the Visible property of your
    controls, and then call it when something changes. The example below shows
    cmd1 only when Text0 equals 1, and cmd2 when the text box = 2 using
    basically the same idea.

    Function ShowHide()
    Me.cmd1.Visible = Nz((Me.[Text0] = 1), False)
    Me.cmd2.Visible = (Nz(Me.[Text0], 0) = 2)
    End Function

    --
    Allen Browne - Microsoft MVP. Perth, Western Australia.
    Tips for Access users - http://allenbrowne.com/tips.html
    Reply to group, rather than allenbrowne at mvps dot org.

    "Adnan" <Adnan@discussions.microsoft.com> wrote in message
    news:8B6A7437-0DC9-4476-BDCA-D7EA67B645BD@microsoft.com...
    > Halloo Fellows,
    > My frmMain is large with lots of button, It looks (designed) like a wab
    > page
    > and has a lot of button all over the place, the question is, when I click
    > on
    > a button or label a want to display just four or five of these buttons and
    > hide all the rests, I can do it by:
    > Me.cmd1.Visible = True
    > Me.Label1.Visible = True
    > Me.cmd2.Visible = False
    > Me.Label2.Visible = False
    > etc.
    >
    > but the code gets extremely long and it confuses me sometimes. Therefore,
    > I
    > was wondering if there is a Module code, which I would then call it with
    > just
    > a line of code instead of typing long codes for each button.
    >
    > Thank you very much for any help provided,
    > Adnan, Computer Science Student.
    >
    > --
    > Please post all your inquiries on this community so we can all benefit -
    > Thank you!
     
  4. Adnan

    Adnan
    Expand Collapse
    Guest

    Allen, thank you for your response – I am sorry I did not thank you earlier.
    Your reply seams to work but I have found another method, I’ve put all those
    Cmds and Lbls onto a form and then I call it from the fmrMain as a subForm
    which will hide or show altogether.
    I will however be using you code later on and am pretty sure that I would
    need your additional help, you’ll se the post.
    Again, THANK YOU!

    Adnan, Computer Science Student
    Kosovo
    --
    Please post all your inquiries on this community so we can all benefit -
    Thank you!


    "Allen Browne" wrote:

    > If you hide a control that has a button attached, that attached label will
    > hide as well, i.e. you don't need to set the Visible property of an attached
    > label.
    >
    > You can certainly create a function that sets the Visible property of your
    > controls, and then call it when something changes. The example below shows
    > cmd1 only when Text0 equals 1, and cmd2 when the text box = 2 using
    > basically the same idea.
    >
    > Function ShowHide()
    > Me.cmd1.Visible = Nz((Me.[Text0] = 1), False)
    > Me.cmd2.Visible = (Nz(Me.[Text0], 0) = 2)
    > End Function
    >
    > --
    > Allen Browne - Microsoft MVP. Perth, Western Australia.
    > Tips for Access users - http://allenbrowne.com/tips.html
    > Reply to group, rather than allenbrowne at mvps dot org.
    >
    > "Adnan" <Adnan@discussions.microsoft.com> wrote in message
    > news:8B6A7437-0DC9-4476-BDCA-D7EA67B645BD@microsoft.com...
    > > Halloo Fellows,
    > > My frmMain is large with lots of button, It looks (designed) like a wab
    > > page
    > > and has a lot of button all over the place, the question is, when I click
    > > on
    > > a button or label a want to display just four or five of these buttons and
    > > hide all the rests, I can do it by:
    > > Me.cmd1.Visible = True
    > > Me.Label1.Visible = True
    > > Me.cmd2.Visible = False
    > > Me.Label2.Visible = False
    > > etc.
    > >
    > > but the code gets extremely long and it confuses me sometimes. Therefore,
    > > I
    > > was wondering if there is a Module code, which I would then call it with
    > > just
    > > a line of code instead of typing long codes for each button.
    > >
    > > Thank you very much for any help provided,
    > > Adnan, Computer Science Student.
    > >
    > > --
    > > Please post all your inquiries on this community so we can all benefit -
    > > Thank you!

    >
    >
    >
     

Share This Page