Results 1 to 7 of 7
  1. #1
    chohan78 is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jan 2015
    Posts
    6

    Question Hiding fields in tab controlled form





    hi,
    I am using a tab controlled form of 5-6 tabs and want to protect 3-4 tabs with a password. Password code is working but not able to hide the data on the forms during the time when I entered the password. Not sure how to use the tag property? ""HELP PLEASE""


    Private Sub TabCtl0_Change()

    Dim strInput As String
    Dim ctl As Control

    If ctl.Tag = "*" Then
    ctl.Visible = False
    End If
    Next ctl


    If TabCtl0.Value = 1 Then
    strInput = InputBox("Please enter a password to access this tab", _
    "Restricted Access")

    If strInput = "" Or strInput = Empty Then
    MsgBox "No Input Provided", , "Required Data"
    TabCtl0.Pages.Item(0).SetFocus
    Exit Sub
    End If


    If strInput = "***" Then

    For Each ctl In Controls
    If ctl.Tag = "*" Then
    ctl.Visible = True
    End If
    Next ctl

    Else
    MsgBox ("Sorry, you do not have access to this information")
    TabCtl0.Pages.Item(0).SetFocus

    Exit Sub
    End If
    End If

    End Sub

    also

    Private Sub Form_Current()


    Dim ctl As Control
    For Each ctl In Controls
    If ctl.Tag = "*" Then
    ctl.Visible = False
    End If
    Next ctl

    End Sub

  2. #2
    ranman256's Avatar
    ranman256 is online now VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,524
    In the loop, you make some visible, but none invisible.
    Code:
    Dim bPassCorrect as Boolean 
    
    bPassCorrect = the result of user entering the password
    
    For each ctl in controls
       If ctl.tag="*" then
              Ctl.visible= bPassCorrect
       Else 
             Ctl.visible=true
       End if
    next

  3. #3
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Note: passwords should be avoided. There are many files on many systems that are unusable due to forgotten passwords or people have left. Have a table of users which contains the login id and a user level. Show data only to those with the correct level. Login id's come from the system - Environ("username").

  4. #4
    chohan78 is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jan 2015
    Posts
    6
    hi,
    still this is not hiding the background fields?

  5. #5
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Another way is to have the fields on those tabs on a subform. When the form opens the subform is invisible. After a successful password entry, change it to visible.

  6. #6
    HiTechCoach's Avatar
    HiTechCoach is offline MS MVP - Access Expert
    Windows 10 Access 2013 32bit
    Join Date
    Jul 2010
    Location
    Oklahoma, USA
    Posts
    702
    The way I handle this is to hide the tabs. Once the password (or any other secutiry method) has been validated, then you make the tabs visible. This only takes a few lines of VBA code.

  7. #7
    HiTechCoach's Avatar
    HiTechCoach is offline MS MVP - Access Expert
    Windows 10 Access 2013 32bit
    Join Date
    Jul 2010
    Location
    Oklahoma, USA
    Posts
    702
    WARNING
    This was corss posted here:

    https://www.access-programmers.co.uk...d.php?t=294048

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Hiding Fields in a Subform
    By swenger in forum Forms
    Replies: 8
    Last Post: 08-22-2016, 02:05 PM
  2. SAMPLE Subform properties controlled by Main Form
    By ItsMe in forum Sample Databases
    Replies: 0
    Last Post: 09-23-2013, 04:58 PM
  3. Replies: 2
    Last Post: 08-01-2013, 01:33 PM
  4. Replies: 3
    Last Post: 10-29-2011, 04:25 AM
  5. Hiding fields in a subform
    By degras in forum Forms
    Replies: 7
    Last Post: 01-18-2011, 10:55 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums