Controls viewing - need help

  • Thread starter Thread starter Dan
  • Start date Start date
D

Dan

Hello:

Let's say I have a Main Menu with two buttons, B1 and B2
that open some data entry screens.

I would need please, a way that some users to see just
business B1 and some B2?! any examples/codes are greatly
appreciated.

Thanks again,
 
Dan,

You could use some simple code in the form's Open event to set the buttons'
Visible or Enabled property to True/False as required. This would require a
table to store the buttons' property value for each user. Assuming the table
is called tblButtons, and the fields are UsrID (text), stsB1 (Yes/No), stsB2
(Yes/No), the form hosting the buttons is called frmMain and the buttons are
called B1 and B2, your code would look something like:

Private Sub frmMain_Open()
Dim CurrUser As String
CurrUser = Application.CurrentUser
Me.B1.Enabled = DLookup("[stsB1]","tblButtons","[UsrID]='" & CurrUser & "'")
Me.B2.Enabled = DLookup("[stsB2]","tblButtons","[UsrID]='" & CurrUser & "'")
End Sub

The above assumes you have implemented Access security, so
Application.CurrentUser returns the user name of each user as logged on to
the database. If you have not, one alternative is to use their Windows logon
(assuming each user has a unique Windows logon name); in that case, change
the line of code to:

CurrUser = Environ("UserName")

HTH,
Nikos
 
Back
Top