MS Access comes with an inbuilt Input Box, that looks simply like a Message Box and can read an Input. This can be quiet useful when you are using values that are not sensitive, if you want to input an override password to reduce the price, or view sensitive information like account numbers. You cannot use the Input Box, you need is a Password box. Unfortunately, Access does not come with this functionality. This article will demonstrate how to implement this Password Box.
A sample DB file has been uploaded in the Gallery section for better understanding - Password Box - A variant of Input Box
You can follow the steps one at a time, to get to where you want it to be.
DoCmd.OpenForm FormName:=
"frmPassword_Box"
, _
View:=acNormal, _
WindowMode:=acDialog
'Call to open the Form
If
CurrentProject.AllForms![frmPassword_Box].IsLoaded
Then
Call_Password_Box = Forms![frmPassword_Box]!Text3.Value
'The Password is obtained to be forwarded to the method that made the call.
DoCmd.Close acForm,
Else
Call_Password_Box = vbNullString
'If Closed or Cancel is pressed a NULL String is returned.
End
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.
Amount_Entered < Default_Value
Call_Password_Box =
"adminApprove"
' do what you want to
MsgBox(
"Sorry the amount entered cannot be approved (OR) Incorrect Password"
, vbCritical)
Since the Function is placed inside a module you can call it from any Form that you desire to give access/provide authentication to.
You are free to use this code in your application, but it would be really great if you could stick a note, acknowledging where you got this code from and the name of the author!