Results 1 to 5 of 5
  1. #1
    khughes46 is offline Competent Performer
    Windows 8 Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Grapevine, TX
    Posts
    231

    How do I test for exactness for a password in the InputBox?

    I have the following code to protect a form:
    If InputBox(“Password?” <> “Oscar” Then
    MsgBox "You are not authorized to open this form”
    Cancel = True
    End If

    However if I type "oscar" it still opens. How do I make it look for "Oscar"?

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,742

  3. #3
    khughes46 is offline Competent Performer
    Windows 8 Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Grapevine, TX
    Posts
    231
    Private Sub Form_Open(Cancel As Integer)
    Dim LResult As Integer
    LResult = StrComp(InputBox("Password"), "Oscar", vbTextCompare)
    If LResult = 0 Then
    MsgBox "You are authorized to open this form"
    Else
    MsgBox "You are not authorized to open this form"
    Cancel = True
    End If

    End Sub
    The above code is still comparing Oscar and oscar as equal

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,742
    Put vbBinaryCompare instead of vbTextCompare

  5. #5
    trevor40's Avatar
    trevor40 is offline Advanced db Manager
    Windows XP Access 2003
    Join Date
    Feb 2014
    Location
    Australia
    Posts
    402
    i'm under thinking this i think

    t= inputbox("Enter Password")
    if t <> "Oscar" then
    else
    end if

    or

    if inputbox("Enter Password") <> "Oscar" then exit sub else docmd.openform "your form"

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

Similar Threads

  1. Replies: 25
    Last Post: 11-23-2014, 02:43 PM
  2. *** mask password in inputbox
    By Kvracing in forum Modules
    Replies: 13
    Last Post: 11-21-2014, 07:22 AM
  3. Test String test besed on table data
    By igourine in forum Programming
    Replies: 3
    Last Post: 12-01-2013, 06:16 AM
  4. Inputbox
    By mladen273 in forum Programming
    Replies: 8
    Last Post: 12-29-2012, 05:32 AM
  5. Keying in Test answers to Access DB from Written Test
    By CityOfKalamazoo in forum Access
    Replies: 3
    Last Post: 03-01-2010, 08:58 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