Results 1 to 4 of 4
  1. #1
    pbDudley is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Mar 2017
    Location
    New Orleans
    Posts
    72

    Configure VBA code in Microsoft Access to hide all access to the queries, tables and modules

    Hello
    I have some code on a login form that I can login as a admin and it will display all of the tables and queries, modules etc in access for me
    But Im trying to hide all of this when another user logs in.

    What I cant hide is the options where a user could potentially unhide the ribbon

    I create a .accde file format as my final access database. Here is my code:
    ption Compare Database
    Private intLogonAttempts As Integer


    Private Sub Form_Load()
    LimitAccess
    Me.cboEmployee.SetFocus
    End Sub


    Private Sub cboEmployee_AfterUpdate()
    'After selecting user name set focus to password field
    Me.txtPassword.SetFocus
    End Sub


    Private Sub cmdLogin_Click()
    'Check to see if data is entered into the UserName combo box
    If IsNull(Me.cboEmployee) Or Me.cboEmployee = "" Then
    MsgBox "You must enter a User Name.", vbOKOnly, "Required Data"
    Me.cboEmployee.SetFocus
    Exit Sub
    End If


    'Check to see if data is entered into the password box
    If IsNull(Me.txtPassword) Or Me.txtPassword = "" Then
    MsgBox "You must enter a Password.", vbOKOnly, "Required Data"
    Me.txtPassword.SetFocus
    Exit Sub
    End If


    'Check value of password in tbl_Employees to see if this matches value chosen in combo box
    If Me.txtPassword.Value = DLookup("Password", "tbl_Employees", "[UserID]=" & Me.cboEmployee.Value) Then
    'Start Main Application Code
    StartApp (Me.cboEmployee.Value)
    Else
    MsgBox "Password Invalid. Please Try Again", vbOKOnly, "Invalid Entry!"


    Me.txtPassword.SetFocus
    End If

    'If User Enters incorrect password 3 times database will shutdown
    intLogonAttempts = intLogonAttempts + 1
    If intLogonAttempts > 3 Then
    MsgBox "You do not have access to this database. Please contact your system administrator.", vbCritical, "Restricted Access!"
    CloseDatabase
    End If
    End Sub

    I want it where no one can accidently access the tables mainly, or modules, but I am able to get to the options section still so I dont know how to hide that as well. Thank you for any help

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 11 Access 2021
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,614
    You may find the following link to be of interest: https://isladogs.co.uk/improve-security/index.html
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    isladogs's Avatar
    isladogs is offline Access MVP / VIP
    Windows 10 Office 365
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    6,204
    My article linked above is in 3 parts. The second article contains detailed information to do all you describe (and more): Improve Access Security 2
    Colin Riddington, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I know I don't know, I keep quiet!

  4. #4
    pbDudley is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Mar 2017
    Location
    New Orleans
    Posts
    72
    Thank you. I got it to work by following the instructions that stated to create a new table that creates a ribbon Remove Ribbon Options, then the code that I currently have along with the hide ribbon worked. Thanks

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

Similar Threads

  1. Replies: 4
    Last Post: 09-20-2018, 11:59 AM
  2. When to use standard modules vs. class modules
    By Access_Novice in forum Programming
    Replies: 7
    Last Post: 01-03-2016, 10:47 PM
  3. Replies: 5
    Last Post: 09-04-2015, 09:55 AM
  4. Replies: 5
    Last Post: 12-05-2013, 07:54 AM
  5. How to configure odbc-connection from vba-code
    By torunsu in forum Import/Export Data
    Replies: 3
    Last Post: 09-06-2011, 07:27 AM

Tags for this Thread

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