By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,804 Members | 1,631 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,804 IT Pros & Developers. It's quick & easy.

Hidding and Unhidding a particular button, depending on who is logged in

P: 12
I have a switchboard on my database that also have a login system.

What i want to happen is to hide the database window, and if a customer logs in, he wont have the button in his switchboard that will allow him to view the database window. And the button will only appear if the Administrator logs in.

How can i set this up, I have only switched of the database window, and have done an external log file using a .txt file. This how far i have gone. I do think i will need an If then statement that will be attached to my switchboard, i just dont know how to implement it. Syntax wise.
Nov 30 '06 #1
Share this Question
Share on Google+
8 Replies


MMcCarthy
Expert Mod 10K+
P: 14,534
I have a switchboard on my database that also have a login system.

What i want to happen is to hide the database window, and if a customer logs in, he wont have the button in his switchboard that will allow him to view the database window. And the button will only appear if the Administrator logs in.

How can i set this up, I have only switched of the database window, and have done an external log file using a .txt file. This how far i have gone. I do think i will need an If then statement that will be attached to my switchboard, i just dont know how to implement it. Syntax wise.
Set the button to invisible on the form and only turn it visible if the Administrator logs in. When Administrator logs out or form is closed then the button should turn invisible again.

Expand|Select|Wrap|Line Numbers
  1.  
  2. Me.buttonName.Visible = True ' makes button visible
  3. Me.buttonName.Visible = False ' makes button invisible
  4.  
Nov 30 '06 #2

P: 12
so how would the IF statement go?
Nov 30 '06 #3

MMcCarthy
Expert Mod 10K+
P: 14,534
so how would the IF statement go?
I would have to know what code you're currently using for your login procedure. If you can post it I can show you how to add the If statement.
Nov 30 '06 #4

P: 12
im using the built in login system of access the .mdw file
Nov 30 '06 #5

P: 12
would it go something like this?

Private Sub Form_Load()
Dim User As String
User = CurrentUser()

If User = PowerAdmin Then
Me.cmdDatabaseWindow.Visible = True ' makes button visible
Else
Me.cmdDatabaseWindow.Visible = False
End If
End Sub

however, this one doesn't seem to work, it hides the button even if the admin is logged in
Nov 30 '06 #6

MMcCarthy
Expert Mod 10K+
P: 14,534
Try putting PowerAdmin in quotes. If that doesn't work check out the Links to Useful sites thread at the top of the Access forum. There is a very good site there on Access security.



would it go something like this?

Private Sub Form_Load()
Dim User As String
User = CurrentUser()

If User = PowerAdmin Then
Me.cmdDatabaseWindow.Visible = True ' makes button visible
Else
Me.cmdDatabaseWindow.Visible = False
End If
End Sub

however, this one doesn't seem to work, it hides the button even if the admin is logged in
Nov 30 '06 #7

P: 12
k thanks for your help it works now
Nov 30 '06 #8

MMcCarthy
Expert Mod 10K+
P: 14,534
k thanks for your help it works now
You're welcome. ;)

Mary
Nov 30 '06 #9

Post your reply

Sign in to post your reply or Sign up for a free account.