A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » New Users
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

HELP!! Form control visibility, based on user level



 
 
Thread Tools Display Modes
  #1  
Old January 19th, 2009, 07:41 PM posted to microsoft.public.access.gettingstarted
gd
external usenet poster
 
Posts: 209
Default HELP!! Form control visibility, based on user level

I have a switchboard divided into 4 sectors, one for each of the security
levels in 004_UserAuth_tbl. I'm trying to make sectors invisible, unless the
user has the proper level to view it. My code below works for level 1,
making everything visible, but level 2 does not make its dector visible (if I
change my level in the table to 2).

What am I doing wrong?

Private Sub Form_Current()
If Val(DLookup("[Level]", "004_UserAuth_tbl", "[UserID]='" &
CurrentUser() & "'")) = 1 Then
Me.boxAcct.Visible = True
Me.lblAcctTitle.Visible = True
Me.cmdAcct1.Visible = True
Me.lblAcct1.Visible = True
Me.cmdAcct2.Visible = True
Me.lblAcct2.Visible = True
Me.cmdAcct3.Visible = True
Me.lblAcct3.Visible = True
Me.boxDCFM_TitleBox.Visible = True
Me.lblDCFM_title.Visible = True
Me.lblAnalyzePaybacks.Visible = True
Me.lblAPC.Visible = True
Me.lblRFC.Visible = True
Me.lblDCMgt.Visible = True
Me.lblProcurement.Visible = True
Me.lblBranch.Visible = True
Me.lblDCFM_PBDM.Visible = True
Me.lblDCFM_NoDM.Visible = True
Me.cmdDCFM_APC.Visible = True
Me.cmdDCFM_RFC.Visible = True
Me.cmdDCFM_DCMgmt.Visible = True
Me.cmdDCFM_Proc.Visible = True
Me.cmdDCFM_Branch.Visible = True
Me.cmdDCFM_PBDM.Visible = True
Me.cmdDCFM_NoDM.Visible = True
Else
Me.boxAcct.Visible = False
Me.lblAcctTitle.Visible = False
Me.cmdAcct1.Visible = False
Me.lblAcct1.Visible = False
Me.cmdAcct2.Visible = False
Me.lblAcct2.Visible = False
Me.cmdAcct3.Visible = False
Me.lblAcct3.Visible = False
Me.boxDCFM_TitleBox.Visible = False
Me.lblDCFM_title.Visible = False
Me.lblAnalyzePaybacks.Visible = False
Me.lblAPC.Visible = False
Me.lblRFC.Visible = False
Me.lblDCMgt.Visible = False
Me.lblProcurement.Visible = False
Me.lblBranch.Visible = False
Me.lblDCFM_PBDM.Visible = False
Me.lblDCFM_NoDM.Visible = False
Me.cmdDCFM_APC.Visible = False
Me.cmdDCFM_RFC.Visible = False
Me.cmdDCFM_DCMgmt.Visible = False
Me.cmdDCFM_Proc.Visible = False
Me.cmdDCFM_Branch.Visible = False
Me.cmdDCFM_PBDM.Visible = False
Me.cmdDCFM_NoDM.Visible = False
End If

If Val(DLookup("[Level]", "004_UserAuth_tbl", "[UserID]='" &
CurrentUser() & "'")) = 2 Then
Me.boxAcct.Visible = True
Me.lblAcctTitle.Visible = True
Me.cmdAcct1.Visible = True
Me.lblAcct1.Visible = True
Me.cmdAcct2.Visible = True
Me.lblAcct2.Visible = True
Me.cmdAcct3.Visible = True
Me.lblAcct3.Visible = True
Else
Me.boxAcct.Visible = False
Me.lblAcctTitle.Visible = False
Me.cmdAcct1.Visible = False
Me.lblAcct1.Visible = False
Me.cmdAcct2.Visible = False
Me.lblAcct2.Visible = False
Me.cmdAcct3.Visible = False
Me.lblAcct3.Visible = False
End If

End Sub
--
GD
  #2  
Old January 20th, 2009, 12:57 AM posted to microsoft.public.access.gettingstarted
Duane Hookom
external usenet poster
 
Posts: 7,177
Default HELP!! Form control visibility, based on user level

I would use the tag property of the controls to set visibility. The code
could then loop through all the controls to check the tag values. You might
be able to use something like the following where you have set the tag
property of controls to something like "sec1".

Dim ctrl as Control
Dim intSecLevel as Integer
Dim strTagValue as String
intSecLevel = Val(DLookup("[Level]", "004_UserAuth_tbl", "[UserID]='" &
CurrentUser() & "'"))
For Each ctrl in Me.Controls
strTagValue = ctrl.Tag & ""
If Instr(strTagValue,"Sec") 0 Then
ctrl.Visible = Instr(strTagValue,Cstr(intSecLevel)) 0
End If
Next

--
Duane Hookom
Microsoft Access MVP


"GD" wrote:

I have a switchboard divided into 4 sectors, one for each of the security
levels in 004_UserAuth_tbl. I'm trying to make sectors invisible, unless the
user has the proper level to view it. My code below works for level 1,
making everything visible, but level 2 does not make its dector visible (if I
change my level in the table to 2).

What am I doing wrong?

Private Sub Form_Current()
If Val(DLookup("[Level]", "004_UserAuth_tbl", "[UserID]='" &
CurrentUser() & "'")) = 1 Then
Me.boxAcct.Visible = True
Me.lblAcctTitle.Visible = True
Me.cmdAcct1.Visible = True
Me.lblAcct1.Visible = True
Me.cmdAcct2.Visible = True
Me.lblAcct2.Visible = True
Me.cmdAcct3.Visible = True
Me.lblAcct3.Visible = True
Me.boxDCFM_TitleBox.Visible = True
Me.lblDCFM_title.Visible = True
Me.lblAnalyzePaybacks.Visible = True
Me.lblAPC.Visible = True
Me.lblRFC.Visible = True
Me.lblDCMgt.Visible = True
Me.lblProcurement.Visible = True
Me.lblBranch.Visible = True
Me.lblDCFM_PBDM.Visible = True
Me.lblDCFM_NoDM.Visible = True
Me.cmdDCFM_APC.Visible = True
Me.cmdDCFM_RFC.Visible = True
Me.cmdDCFM_DCMgmt.Visible = True
Me.cmdDCFM_Proc.Visible = True
Me.cmdDCFM_Branch.Visible = True
Me.cmdDCFM_PBDM.Visible = True
Me.cmdDCFM_NoDM.Visible = True
Else
Me.boxAcct.Visible = False
Me.lblAcctTitle.Visible = False
Me.cmdAcct1.Visible = False
Me.lblAcct1.Visible = False
Me.cmdAcct2.Visible = False
Me.lblAcct2.Visible = False
Me.cmdAcct3.Visible = False
Me.lblAcct3.Visible = False
Me.boxDCFM_TitleBox.Visible = False
Me.lblDCFM_title.Visible = False
Me.lblAnalyzePaybacks.Visible = False
Me.lblAPC.Visible = False
Me.lblRFC.Visible = False
Me.lblDCMgt.Visible = False
Me.lblProcurement.Visible = False
Me.lblBranch.Visible = False
Me.lblDCFM_PBDM.Visible = False
Me.lblDCFM_NoDM.Visible = False
Me.cmdDCFM_APC.Visible = False
Me.cmdDCFM_RFC.Visible = False
Me.cmdDCFM_DCMgmt.Visible = False
Me.cmdDCFM_Proc.Visible = False
Me.cmdDCFM_Branch.Visible = False
Me.cmdDCFM_PBDM.Visible = False
Me.cmdDCFM_NoDM.Visible = False
End If

If Val(DLookup("[Level]", "004_UserAuth_tbl", "[UserID]='" &
CurrentUser() & "'")) = 2 Then
Me.boxAcct.Visible = True
Me.lblAcctTitle.Visible = True
Me.cmdAcct1.Visible = True
Me.lblAcct1.Visible = True
Me.cmdAcct2.Visible = True
Me.lblAcct2.Visible = True
Me.cmdAcct3.Visible = True
Me.lblAcct3.Visible = True
Else
Me.boxAcct.Visible = False
Me.lblAcctTitle.Visible = False
Me.cmdAcct1.Visible = False
Me.lblAcct1.Visible = False
Me.cmdAcct2.Visible = False
Me.lblAcct2.Visible = False
Me.cmdAcct3.Visible = False
Me.lblAcct3.Visible = False
End If

End Sub
--
GD

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 12:50 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.