Password Box - A variant of Input Box.

pr2-eugin

Super Moderator
Local time
Today, 10:10
Joined
Nov 30, 2011
Messages
8,494
I am not sure if this is worthy of posting, but when I started I found it a bit difficult to incorporate. So I am posting to help someone who might be looking for something like this.

This is a simple form that acts like the Input Box but only difference is that it collects password, instead of normal text. This can be used on any other forms to authenticate something..
Maybe for overriding default values/changing the data for security reasons. The limits of this might be endless.

STEP 1: Create an Unbound Form call it frmPassword_Box, with a Text field (that will be your input box), two buttons OK and CANCEL.
On the 'On_Click' event of the 'CANCEL' button close the form, on the 'On_Click' event of 'OK' button make the FORM invisible i.e. until the value has been validated for then you can close it.
STEP 2: In design mode change the 'Input Mask' of the Text Box to Password. Thus we can make sure it appears to be DITO of the Input box, but for Passwords.
STEP 3: Create a Function inside a common module call it Call_Password_Box, then enter the code inside
Code:
DoCmd.OpenForm FormName:="frmPassword_Box", _
    View:=acNormal, _
    WindowMode:=acDialog                
   [COLOR=SeaGreen][B] 'Call to open the Form[/B][/COLOR]
    
If CurrentProject.AllForms![frmPassword_Box].IsLoaded Then
    Call_Password_Box = Forms![frmPassword_Box]!Text3.Value 
    [COLOR=SeaGreen][B]'The Password is obtained to be forwarded to the method that made the call.[/B][/COLOR]
    DoCmd.Close acForm, "frmPassword_Box"
Else
    Call_Password_Box = vbNullString          
    [COLOR=SeaGreen][B]'If Closed or Cancel is pressed a NULL String is returned.[/B][/COLOR]
End If
STEP 4: Save all changes, compile to see if there are any errors.

Now you have a 'Authentication Terminal' which can be called for when you need it.
Usage maybe for single authentication (maybe a default Admin password) or use a Table with list of all passwords and ID and use DLookUp for comparing.
something like..
Code:
If Amount_Entered < Default_Value Then
    If Call_Password_Box = "adminApprove" Then
        ' do what you want to
    Else
        MsgBox("Sorry the amount enterd cannot be approved (OR) Incorrect Password", vbCritical)
    End If
End If

Since the Function is placed inside a module you can call it from any Form that you desire to give access/provide authentication to.
Hope this helps, as it has helped me.
 
I am attaching the working module of the Password Box. Here it goes..
 

Attachments

Excellent. Thank you so much for this and your help!
 
Last edited:

Users who are viewing this thread

Back
Top Bottom