Setting control properties via code

  • Thread starter Thread starter tsison7
  • Start date Start date
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.
 
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
 
Back
Top