Setting control properties via code

T

tsison7

I want to turn the visible property of a control button on or off depending
on who's logged in (ie. Administrator, Salesperson etc).

I think I would enter the code to run when that form is opened but I'm
having trouble with how to write the code.
 
K

Ken Snell \(MVP\)

Use the form's Load event to run code similar to this:

Private Sub Form_Load()
' you can use a function to get the user name -- not sure how you're doing
that
' in your specific situation, so I've just put a "text string"
' ("WhatTheUserNameIs") here for now
Select Case "WhatTheUserNameIs"
Case "Administrator"
Me.CommandButtonName.Visible = True
Case "Salesperson", "Clerical"
Me.CommandButtonName.Visible = False
Case Else
Me.CommandButtonName.Visible = False
End Select
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top