Re: Inputbox maybe?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: George Nicholson (JunkGeorgeN_at_msn.com)
Date: 08/25/04


Date: Wed, 25 Aug 2004 13:19:52 -0500

Untested aircode. Using just the Input Box, this relies on the user actually
typing "Cancel" (or the correct password) to exit the loop.

Sub InputPassword(strPassword as string)
Dim bolOK as Boolean
Dim strResult as String

bolOK = False
Do
    strResult = Trim(InputBox("Please enter the Password or Type CANCEL to
abort:","Enter Password"))

    Select Case strResult
        Case "CANCEL", "Cancel", "cancel")
            ' Code to exit back to Previous form
            GoTo ExitSub ' *NOT* "Exit Do"
        Case Else
            If strResult = strPassword then
                bolOK = True
            Else
                ' Do nothing: code will loop and repeat the InputBox
            End If
   End Select
Loop While bolOK = False

' ......Code that allows access goes here
' (correct password must have been entered to have gotten here)

ExitSub

-- 
George Nicholson
Remove 'Junk' from return address.
"John" <j> wrote in message news:uWR$8nqiEHA.2180@TK2MSFTNGP10.phx.gbl...
> I have a form with a command button that opens another form. What I would
> like to do is when the user clicks on the button, as box appears asking to
> enter the pasword. The user will all ready know the password. If the
> password is entered wrong I would like the user to be given two choices.
One
> to re-enter the password, which if is correct will go ahead and open the
> form. The second choice will be cancel which will return back to the
> previous form. I have tried several variations of the inputbox, msgbox's
and
> am not able to make it work right. My form names are CustInfo, CustAdm.
> Please help I need working code.
>
> Thanks
>
>


Relevant Pages

  • Input a string (again)
    ... After I'm now able to input a string (30 ... chars), I need to cancel the loop in the following source, when the user ... All I want is to cancel that loop when nothing is entered, ...
    (comp.lang.ada)
  • Re: Popup Form to Delete Record
    ... Put a text box on the form, and set its Input Mask property to: ... Provide Ok and Cancel buttons on this form. ... rather than allenbrowne at mvps dot org. ... > delete the record on the form below when the type in the correct password. ...
    (microsoft.public.access.formscoding)
  • Re: Macro button that asks for password before proceeding?
    ... On Aug 5, 12:43 pm, Jacob Skaria ... limbo until you enter the correct password. ... before this macro button is run? ... you could also put a conditional loop that gives back a message as in ...
    (microsoft.public.excel.programming)
  • Logon security for Windows 98
    ... password appears at boot up. ... If I don't enter the correct password and select "OK" I am ... denied access to the system. ... Of course if I just select "Cancel" I get logged in just ...
    (microsoft.public.security)
  • Re: How to use DAO to access a password protected Access database
    ... DBFilename is a string containing the database path+filename, ... string containing just the password. ... > But even I put the correct password to sConnection, ...
    (microsoft.public.vb.general.discussion)