vba - Command Button Visibitly based on Application.Username -


i looking @ creating administration button on user-form.

now want against application.username determine whether button visible or not.

my current code is:

private sub adminbtn()  if application.username = "peter.mogford" admincmd.visible = false else admincmd.visible = true end if  end sub 

i have put myself in test , asked visibility false reason still showing.

i'm not sure whether has me writing code in user-form instead of module or that.

please can offer bit of advise.

thanks in advance

the practice here in case need update visibility once form shown using form constructor.

use this:

public class form1  public sub new()     initializecomponent()      if application.username = "peter.mogford"     admincmd.visible = false     else     admincmd.visible = true     end if end sub  end class 

when writing custom form constructor, important call initializecomponent() function, controls initialization, before call of them.


Comments

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -

Nuget pack csproj using nuspec -