Results 1 to 13 of 13
  1. #1
    5 Star Lounger
    Join Date
    May 2003
    Location
    Sheffield, Yorkshire
    Posts
    951
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Hide Button (2003)

    I know how to hide a command button on a form, except to a certain user who is logged on the network, but can this be done on a Switchboard? I know the easiest method would be the form, but I would have to re-create a form, as the switchboard already exists.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Hide Button (2003)

    If you mean one of the standard switchboard buttons, you'd have to tweak the code that is created by the Switchboard Manager. If you want to place an extra button on the switchboard, you can use code similar to what you already have.

    Rob, you have posted several questions this year: <post#=623552>post 623552</post#>, <post#=628748>post 628748</post#>, <post#=631541>post 631541</post#>, <post#=632636>post 632636</post#>, and <post#=634100>post 634100</post#>, but you haven't provided any feedback to the replies you received, so other Loungers reading those threads have no idea whether the replies were helpful.

  3. #3
    5 Star Lounger
    Join Date
    May 2003
    Location
    Sheffield, Yorkshire
    Posts
    951
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Hide Button (2003)

    Thanks. I'll look at the switchboard code. Thanks again.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Hide Button (2003)

    If you want to tweak the switchboard code, take a look at the FillOptions procedure. This procedure is used to set the captions of the labels on the form, and to toggle the visibility of the buttons and labels. You'd have to add code to the While ... Wend loop, for example:

    While (Not (rs.EOF))
    If CurrentUser = "RobM" Or Not rs!<!t>[ItemText]<!/t> = "Secret Item" Then
    Me("Option" & rs!<!t>[ItemNumber]<!/t>).Visible = True
    Me("OptionLabel" & rs!<!t>[ItemNumber]<!/t>).Visible = True
    Me("OptionLabel" & rs!<!t>[ItemNumber]<!/t>).Caption = rs!<!t>[ItemText]<!/t>
    End If
    rs.MoveNext
    Wend

    This will keep an item with caption "Secret Item" unless the current user is RobM.

  5. #5
    5 Star Lounger
    Join Date
    May 2003
    Location
    Sheffield, Yorkshire
    Posts
    951
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Hide Button (2003)

    That works, but I don't know if I've done it right. It hides all buttons except one, which I suppose it should do. All I want to do is, hide a button that opens a report.

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Hide Button (2003)

    Perhaps you inverted the condition. Check it carefully.

  7. #7
    5 Star Lounger
    Join Date
    May 2003
    Location
    Sheffield, Yorkshire
    Posts
    951
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Hide Button (2003)

    I'm not getting the results I'm expecting. I copied/pasted the code into the While......Wend loop, but changed the user to someone else expecting buttons to be hidden, but they all appear, as they do with RobM. There are 4 buttons. Add Record, Edit Record, Print Report, and Quit. I only want to hide Print Report, if the user is not me.

  8. #8
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Hide Button (2003)

    Are you using user-level security? I assumed you did. (I know, I know, one should never assume, but ...)

  9. #9
    5 Star Lounger
    Join Date
    May 2003
    Location
    Sheffield, Yorkshire
    Posts
    951
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Hide Button (2003)

    Not security as such. I'm using GetNetUser code that you advised in a previous post (which works quite well in the other database). So I assumed as well, that if I substituted my name for someone elses in the code, it would hide the appropriate button from me.

  10. #10
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Hide Button (2003)

    This works as intended for me:

    If GetNetUser = "Hans" Or Not rs![ItemText] = "Open Manager Report" Then

    where "Hans" is my Windows logon name and "Open Manager Report" is the name of the item that should only be visible to me.

    Note: it shouldn't be the first item on a switchboard page. The first item is never hidden.

  11. #11
    5 Star Lounger
    Join Date
    May 2003
    Location
    Sheffield, Yorkshire
    Posts
    951
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Hide Button (2003)

    Sorry about this Hans. Your last instruction does what I intended, but now I've been asked to include my boss also. How do I get it to work for two users?

  12. #12
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Hide Button (2003)

    Try

    If GetNetUser = "RobM" Or GetNetUser = "MyBoss" Or Not rs![ItemText] = "Open Manager Report" Then

    with the appropriate names substituted, of course.

  13. #13
    5 Star Lounger
    Join Date
    May 2003
    Location
    Sheffield, Yorkshire
    Posts
    951
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Hide Button (2003)

    Thanks again Hans. That did the trick.

Posting Permissions

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