Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

MSAccess Page Controls

Posted on 2011-09-14
7
Medium Priority
?
338 Views
Last Modified: 2012-08-14
I am trying to set up controls to make the tabs (pages) on my form visable/hide based on
the security of the user.  I've got some code to copy, but I don't know how to set up the
reference to the tabs.  I understand that pages(0) refers to the first tab of the form.  What is the "TabMain" referring to?
Thanks, Lynn
Set rstRoles = db.OpenRecordset(strSQL)
        If Not rstRoles.EOF And Not rstRoles.BOF Then
            rstRoles.MoveFirst
            Do Until rstRoles.EOF
                    Select Case rstRoles.Fields("roleName")
                    Case "Processor"
                        Me.TabMain.Pages(3).Visible = True
                        Me.TabMain.Pages(4).Visible = True
                        Me.TabMain.Pages(5).Visible = True
                    Case "Security Administrator"
                        Me.TabMain.Pages(1).Visible = True
                        Me.TabMain.Pages(4).Visible = True
                        Me.TabMain.Pages(5).Visible = True
                    Case "System Administrator"
                        Me.TabMain.Pages(0).Visible = True
                        Me.TabMain.Pages(4).Visible = True
                        Me.TabMain.Pages(5).Visible = True
                    End Select
                rstRoles.MoveNext
            Loop
        End If
    Set rstRoles = Nothing
    Set db = Nothing

Open in new window

0
Comment
Question by:Lambel
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 61

Accepted Solution

by:
mbizup earned 2000 total points
ID: 36538684
TabMain is the tab control itself, which includes the pages and tabs.
0
 

Author Comment

by:Lambel
ID: 36538735
I am still confused.  
I have a form named frmReportGenerator, with pages (tabs) named and in the following order:
Report Parameters, Recipeint-Regions, Sites-Region, Recipients, Sites, Regions, Email Message,
Users, User Roles.

To hide the last two pages (Users and User Roles), what is the correct syntax?  

I've attached a printscreen of the form for reference. printscreen-frmReportGenerator.doc printscreen-frmReportGenerator.doc
0
 
LVL 61

Expert Comment

by:mbizup
ID: 36538936
What is the actual trouble you are having with the code you have posted?

If I'm understanding your request properly, at a minimum, you would need to also specify which pages are hidden.  Also, it looks like you would probably want your sql statement to look up the role of a particular user and then set the tabs visible or hidden ONCE, after the role has been looked up.  Your code currently has the tab visibility code inside your recordset loop.  That doesn't seem quite right.

I think you need something more like this:

dim pg as page
for each pg in me.tabmain.pages
        pg.visible = false    ' start out with all pages hidden
next

' look up the user's role
Set rstRoles = db.OpenRecordset(strSQL)
        if rstRoles.recordcount = 0 then
                msgbox "no role found for this user"
                Exit sub ' (or function)
        end if
                    Select Case rstRoles.Fields("roleName")
                    Case "Processor"
                        Me.TabMain.Pages(3).Visible = True
                        Me.TabMain.Pages(4).Visible = True
                        Me.TabMain.Pages(5).Visible = True
                    Case "Security Administrator"
                        Me.TabMain.Pages(1).Visible = True
                        Me.TabMain.Pages(4).Visible = True
                        Me.TabMain.Pages(5).Visible = True
                    Case "System Administrator"
                        Me.TabMain.Pages(0).Visible = True
                        Me.TabMain.Pages(4).Visible = True
                        Me.TabMain.Pages(5).Visible = True
                    End Select
     Set rstRoles = Nothing
    Set db = Nothing
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 61

Expert Comment

by:mbizup
ID: 36538950
The idea behind what I just posted is that the person using the database has a given 'role'.  Based on that role, you are only allowing them to see certain pages.

Is that understanding correct?
0
 

Author Comment

by:Lambel
ID: 36539258
frmReportGenerator.Pages(1).Visible = False
                        frmReportGenerator.Pages(2).Visible = False
                        frmReportGenerator.Pages(3).Visible = False
                        frmReportGenerator.Pages(4).Visible = False
                        frmReportGenerator.Pages(5).Visible = False
                        frmReportGenerator.Pages(6).Visible = False
                        frmReportGenerator.Pages(7).Visible = False
                        frmReportGenerator.Pages(8).Visible = False
0
 

Author Comment

by:Lambel
ID: 36539264
See my comments above - that syntax fixed it.  Thanks for your help
Lynn
0
 
LVL 61

Expert Comment

by:mbizup
ID: 36539495
Glad to help out
0

Featured Post

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question