Results 1 to 5 of 5
  1. #1
    Jeff G is offline Novice
    Windows 10 Access 2016
    Join Date
    Mar 2019
    Posts
    8

    Add Button to Enter Password on form to access database.

    I have a database set-up that when it's opened it autoexec's a Form. The person inputs the necessary info and must click on two buttons. A checkmark button that inputs the info to a table and populates and fresh form and the other will exit the database and close the program. I have it set that way so no one can access the database tables, queries, etc... I want to add a new button for "Admin" personnel. When clicked I want it to populate for a password and then close the form keeping the database open. After some intense googling and looking on this website I believe I need to set up the button with a code, which I'm new to. The code I found is giving me trouble running. Any input is greatly appreciated. Here's the code:



    Code:
    Private Sub Command98_Click()
    
    
    Dim password As Variant
    
    
    password = Application.InputBox("Please Enter Password", "ADMIN Database")
    
    
    Select Case password
    
    
    Case Is = False
    
    
        'do nothing
    
    
    Case Is = "password"
    
    
    DoCmd.Close acForm, "Input Flight"
    
    
    Case Else
    
    
    MsgBox "The Password You Entered is Incorrect"
    
    
    End Select
    
    
    End Sub
    Last edited by Jeff G; 03-27-2019 at 09:35 PM.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    Please post code within CODE tags to retain indentation and readability.

    "Trouble" means what - error message, wrong result, nothing happens?

    Have you step-debugged?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Jeff G is offline Novice
    Windows 10 Access 2016
    Join Date
    Mar 2019
    Posts
    8
    I edited the original post to add the Code tags. Thanks for the heads up on that. I'll try the debugger. Here's a snippet of the error I receive.

    Click image for larger version. 

Name:	Error.JPG 
Views:	11 
Size:	85.2 KB 
ID:	37951

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    Remove the 'Application.' prefix.

    Watch the Intellisense tips as you type. InputBox is not a method of Application.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    Jeff G is offline Novice
    Windows 10 Access 2016
    Join Date
    Mar 2019
    Posts
    8
    Perfect. That did the trick. Thanks for the help!!

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

Similar Threads

  1. Replies: 8
    Last Post: 03-27-2019, 07:31 AM
  2. Replies: 8
    Last Post: 05-08-2016, 09:41 AM
  3. button a form to open But with password
    By azhar2006 in forum Forms
    Replies: 2
    Last Post: 04-08-2015, 11:24 AM
  4. Replies: 6
    Last Post: 03-25-2015, 10:50 AM
  5. Replies: 5
    Last Post: 11-26-2013, 09:20 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