Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

If statement issues with Currentuser() specified

Status
Not open for further replies.

DMBLuva

Technical User
Jul 16, 2008
27
US
Hi all,

I'm SUPER new to posting to a forum, but I have been using your site for sometime now and appreciate all your great advice.
With that said. I am working on a workflow management db for my group. There are 3 admins and 4 users. I have it set up currently through the Access Security wizard. My issue sounds simple, but I can't get the darn thing to work.

All I want is for one of my forms to disable certain buttons if the person is NOT in the admin group. If that cannot be done easily, I would like to tell it if that current user is not one of these 3 people, disable the buttons. I will supply my code below. The problem is when I get more than one person in the if statement, it ends up disabling the buttons for every users.

I would appreciate any help you can give me. If you can think of an easier way, that would be great too. I can muttle my way through coding VBA.

Private Sub Form_load()
DoCmd.Maximize

If Not Application.CurrentUser() = "hendrixs" Then
Me.cmdLeadFormOpen.Visible = False
Me.cmdCurrentOpenJobsReport.Enabled = False
Me.Command36.Enabled = False
Me.cmdRptPastDue.Enabled = False
Me.cmdReportAssignedTo.Enabled = False
Me.cmdReportJobsByCategory.Enabled = False
Me.cmdReportByStatus.Enabled = False

ElseIf Not Application.CurrentUser() = "mbaptist" Then
Me.cmdLeadFormOpen.Enabled = False
Me.cmdCurrentOpenJobsReport.Enabled = False
Me.Command36.Enabled = False
Me.cmdRptPastDue.Enabled = False
Me.cmdReportAssignedTo.Enabled = False
Me.cmdReportJobsByCategory.Enabled = False
Me.cmdReportByStatus.Enabled = False

ElseIf Not CurrentUser() = "olopez" Then
Me.cmdLeadFormOpen.Enabled = False
Me.cmdCurrentOpenJobsReport.Enabled = False
Me.Command36.Enabled = False
Me.cmdRptPastDue.Enabled = False
Me.cmdReportAssignedTo.Enabled = False
Me.cmdReportJobsByCategory.Enabled = False
Me.cmdReportByStatus.Enabled = False
End If


Thank you in advance.
 
Maybe get rid of the negative logic, and interrogate to see who the user is, instead of who it is not; then set the availability of controls accordingly?
The problem is when I get more than one person in the if statement
How does Application.CurrentUser() return more than one value?

"Don't be irreplaceable. If you can't be replaced, you can't be promoted."
 
That did it thank you!

I called the user first -
user =currentuser()


Thank you again for the quick response that was driving me nuts!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top