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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Subform visible only to certain currentuser() of mainform 1

Status
Not open for further replies.

cdgeer

IS-IT--Management
Apr 8, 2008
133
US
I have a mainform with a textbox that returns the CurrentUser(). I would like to have the subform on this mainform only be visible to certain currentusers. Could someone show me how to write the code to change the visible property based on who the currentuser is?

Form.textbox is called [NonEmployee Personnel].WelcomeUser

Subform is called FinancialInfo

Thanks for any help.

 
In the open event of the form, try

If Forms![NonEmployee Personnel].WelcomeUser = "Whatever" Then
Me.FinancialInfo.Visible = True
Else
Me.FinancialInfo.Visible = False
End If

Paul
MS Access MVP 2007/2008
 
Thanks Paul! Works perfect,Gold star for you!
One more question though. If I want to check against more than 1 user?

If Forms![NonEmployee Personnel].WelcomeUser = "Whatever" or "Whatever2" or "Whatever3" Then...

How is that written? and would it be possible to create a table of values that it could read from? That way I could create a popup form that an admin could assign "Whoever" to the group.

Thanks!
 
The syntax for that would be:

If Forms![NonEmployee Personnel].WelcomeUser = "Whatever" or Forms![NonEmployee Personnel].WelcomeUser = "Whatever2" or Forms![NonEmployee Personnel].WelcomeUser = "Whatever3" Then

But for flexibility I would probably create the table. You could then use a DLookup or open a recordset to determine the status of the current user, and test that.

Paul
MS Access MVP 2007/2008
 
OK, great!
Thanks Paul! You've been a lot of help.

 
No problem! Post back if you get stuck.

Paul
MS Access MVP 2007/2008
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top