View Full Version : Button visible or invisible based on who the user is??


Johnnyw
09-10-2001, 07:38 AM
I have a main pop up form that allows users to select which form they want to open. There are 5 users who each have their own form, but the main screen shows all 5 buttons that links to all 5 forms. I want to only show the button that belongs to that user. I have set up Access permission security to each of these forms. Basically I want a statement that does something like: If the current user is ________ Then "This button" is visible.

Maybe I've answered my own question but I do not know much VB. Anyones help is appreciated.

DaleFromEngland
09-10-2001, 07:48 AM
Why dont you just create a Data protection on the button. (password prompt) This way you have all 5 users seeing the buttons, but if they dont have the correct password then they wont be able to access the button. You could try this:

Dim strPasswd

strPasswd = InputBox("Please Enter your Password in the box below.", "Restricted Command button")

If strPasswd = "YOUR PASSWORD" Then

(PUT WHAT EVER YOU WANT TO RESTRICT IN THIS PART, SO FOR INSTANCE me.delete = "False"
WOULD DISABLE A DELETE BUTTON)

Else

Exit Sub

End If

Make sure you put this on the ONCLICK EVENT.


It is worth a try.

Hope i have helped.

[This message has been edited by DaleFromEngland (edited 09-10-2001).]

Opengrave
09-10-2001, 08:00 AM
See the example here (http://www.access-programmers.co.uk/ubb/Forum4/HTML/004172.html) for more help. Basically you set the Visible property to 'false' as part of an an if-then.