InputBox Mask ****** & Call it 3 times.

A

Andy

Hi;

Have created frmPasswordEnter. This frmPasswordEnter opens the first time a
User enters the DBase. It is triggered by an If/Then function in the
"AutoExec" macro.
Public Function PasswordPrompt()
Dim strInput As String, strMsg As String

strMsg = "Enter your Password."
strInput = InputBox(Prompt:=strMsg,

If(isnull((DLookup("[Password]", "tblMainTbl") then
DoCmd.OpenForm "frmPasswordEnter"
Else
If strInput Like (DLookup("[Password]", "tblMainTbl")) Then
DoCmd.OpenForm "frmMainData"
Else
MsgBox "That is not the correct password. Please enter the correct
password."
End If

This all works fine up to a point.

First need to "Mask" the Input password.
E.G.: Instead of "MyPassword" it should show **********

Second how do You get the Inputbox to prompt 3 times.
E.G.: InputBox WrongPassword then InputBox WrongPassword then InputBox
WrongPassword then MSGBOX "Dbase is Closing"

Have read Microsoft's Supports including "209871 How to Create a Password
Protected Form or Report" but that requires a separate form with it's own
module and the code is long and cumbersome.
Believe the approach described above is a lot simpler and it doesn't take up
as much "Real Estate" as Microsoft's solution.

Would someone be so kind as to point me in the correct direction?

Thank You for reading this post.

Andy
 
D

David W

This is what I did, I use it for both the opening and some forms that I want
administrative rights for the user to continue.

I made a form that is bound to a user table(name of users and passwords, in
the table I set the passwords property to password. Then I added a
combobox(combo21, users name from field), textbox(vat2 for the
password(unbound)), textbox(vat1,from the password field), textbox(counter,
to count the number of retries(unbound)) then use the following code.

Use the password option for your textboxes that use a password.

Make invisible - vat1

Dim strMsg As String
If IsNull(Me.Combo21) Then
MsgBox "Please Select a Name First", vbExclamation + vbOKOnly, "No Name
Selected"
Me.Combo21.SetFocus
Me.vat2 = ""
End If
If Me.vat2 = Me.vat1 Then
DoCmd.Close
'Do what ever

End If
If Me.vat2 <> Me.vat1 Then
If IsNull(Me.counter) Or Me.counter = "" Then
MsgBox "Your Password does not match!", vbExclamation + vbOKOnly,
"PLEASE TRY AGAIN!"
Me.counter = "1"
Me.vat2 = ""
Me.Combo21.SetFocus
Me.vat2.SetFocus
Exit Sub
End If
End If
If Me.counter = "1" Then
MsgBox "Your Password does not match!", vbExclamation + vbOKOnly,
"PLEASE TRY AGAIN!"
Me.counter = "2"
Me.vat2 = ""
Me.Combo21.SetFocus
Me.vat2.SetFocus
Exit Sub
End If
If Me.counter = "2" Then
MsgBox "Your Passwords have not matched the past 2 times, Please
contact the administrator for futher assistance.", vbExclamation + vbOKOnly,
"Invalid Password!"
Me.counter = ""
DoCmd.Quit
End If
End Sub

Hope this helps
David
 
T

Tim Ferguson

First need to "Mask" the Input password.
E.G.: Instead of "MyPassword" it should show **********

Cannot with an input box: you'll need to create an unbound form with a
single textbox (txtInput) and a single command button (cmdOK)

Set the textbox InputMask to "password".

You can do the looking up in the code behind the form; then if it's
correct you hide the form (me.visible = false) and if it's wrong then you
unload it.
Second how do You get the Inputbox to prompt 3 times.
E.G.: InputBox WrongPassword then InputBox WrongPassword then InputBox
WrongPassword then MSGBOX "Dbase is Closing"

set a counter: increment it every time the user clicks the OK button.
Don't unload the form unless the guess is wrong and the counter reaches
three.

The calling code can (1) see if the form is still loaded and invisible,
read the password text and then unload it; or (2) if it's unloaded then
there was no successful attempt.
Have read Microsoft's Supports including "209871 How to Create a
Password Protected Form or Report" but that requires a separate form
with it's own module and the code is long and cumbersome.

Not really: a dozen lines or so of code.
Believe the approach described above is a lot simpler and it doesn't
take up as much "Real Estate" as Microsoft's solution.

Only little bit simpler: the complexity is all this database looking up
stuff you are doing (which is not particularly safe anyway). It might be
a better idea to store the password in the database Properties, where
they can't be seen except using VBA code, rather than in a table which
can be read by anyone. At least you might want to encrypt it?

In any case, there is no way of passwording an InputBox.

Hope that helps


Tim F
 
K

Klatuu

There is no formatting for an input box. You will need to use your password
input form instead. Instead of using an Autoexec macro, make your password
form the form to show on open. (Tools->Startup, Display Form/Page:). To mask
the password input, use the input mask property of the text box. Set it to
Password. It is a named format that will take care of that for you.

Then put your code in After Update event of the password text box:

Private Sub txtPassword_AfterUpdate()
Dim lngRetries as Long
Dim varGoodWord as Variant
varGoodWord = (DLookup("[Password]", "tblMainTbl"))
If Isnull(varGoodWord) Then
DoCmd.OpenForm "frmMainData"
Else
Do While lngRetries < 3
If Me.txtPassword = varGoodWord then
DoCmd.OpenForm "frmMainData"
Exit Do
Else
MsgBox "That is not the correct password. " _
& "Please enter the correct password."
lngRetries = lngRetries + 1
Me.txtPassword.SetFocus
End If
End Do
If lngRetries = 3 Then
DoCmd.Quit
End If
End If
DoCmd.Close
End Sub
 
A

Andy

Gentlemen;

Thank You for the replies.

All of Your answers are more streamlined then that offered by Microsoft.

You have put a smile on this face ;-)

Andy
 
R

Rob Oldfield

Just to check Andy... you know that any of these methods (and that also
includes the MS one) can be overridden by just holding down the Shift key?

If you want any level of real security you need to use user level security.


Andy said:
Gentlemen;

Thank You for the replies.

All of Your answers are more streamlined then that offered by Microsoft.

You have put a smile on this face ;-)

Andy

Andy said:
Hi;

Have created frmPasswordEnter. This frmPasswordEnter opens the first
time
a
User enters the DBase. It is triggered by an If/Then function in the
"AutoExec" macro.
Public Function PasswordPrompt()
Dim strInput As String, strMsg As String

strMsg = "Enter your Password."
strInput = InputBox(Prompt:=strMsg,

If(isnull((DLookup("[Password]", "tblMainTbl") then
DoCmd.OpenForm "frmPasswordEnter"
Else
If strInput Like (DLookup("[Password]", "tblMainTbl")) Then
DoCmd.OpenForm "frmMainData"
Else
MsgBox "That is not the correct password. Please enter the correct
password."
End If

This all works fine up to a point.

First need to "Mask" the Input password.
E.G.: Instead of "MyPassword" it should show **********

Second how do You get the Inputbox to prompt 3 times.
E.G.: InputBox WrongPassword then InputBox WrongPassword then InputBox
WrongPassword then MSGBOX "Dbase is Closing"

Have read Microsoft's Supports including "209871 How to Create a Password
Protected Form or Report" but that requires a separate form with it's own
module and the code is long and cumbersome.
Believe the approach described above is a lot simpler and it doesn't
take
up
as much "Real Estate" as Microsoft's solution.

Would someone be so kind as to point me in the correct direction?

Thank You for reading this post.

Andy
 
A

Andy

Rob;

Yes I do know that; so I followed this from Access Help. Is it sufficient?:

If you clear the Use Access Special Keys check box and you specify a custom
menu bar in the Menu Bar box, the built-in menu bar isn't accessible.

If you clear both the Use Access Special Keys check box and the Display
Database Window check box, it's possible that users can still access the
Database window. This can happen when a user tries more than once to open
the same Access database or Access project from the list of
most-recently-used Access databases or Access projects, which automatically
appears on the File menu. To prevent users from accessing this list, replace
the File menu with your own custom menu.

Andy
 
A

Andy

Hi;

Have spent the last few hours trying to get Klatuu's code running correctly.

I know I have a lot to more to learn.

The code just doesn't work correctly. The frm is closed after the first try
and VBA is showing "End Do" in red.

Using A2K so changed it to Exit Do and that still doesn't work.

Woul You be so kind to offer a little more help?

Andy
 
R

Rob Oldfield

Nope. It isn't. Go into Access directly (i.e. without double clicking an
mdb or using a shortcut to an mdb), File, Open, hold down the Shift key
while you hit OK and you bypass anything like that.


Andy said:
Rob;

Yes I do know that; so I followed this from Access Help. Is it sufficient?:

If you clear the Use Access Special Keys check box and you specify a custom
menu bar in the Menu Bar box, the built-in menu bar isn't accessible.

If you clear both the Use Access Special Keys check box and the Display
Database Window check box, it's possible that users can still access the
Database window. This can happen when a user tries more than once to open
the same Access database or Access project from the list of
most-recently-used Access databases or Access projects, which automatically
appears on the File menu. To prevent users from accessing this list, replace
the File menu with your own custom menu.

Andy

Andy said:
Hi;

Have created frmPasswordEnter. This frmPasswordEnter opens the first
time
a
User enters the DBase. It is triggered by an If/Then function in the
"AutoExec" macro.
Public Function PasswordPrompt()
Dim strInput As String, strMsg As String

strMsg = "Enter your Password."
strInput = InputBox(Prompt:=strMsg,

If(isnull((DLookup("[Password]", "tblMainTbl") then
DoCmd.OpenForm "frmPasswordEnter"
Else
If strInput Like (DLookup("[Password]", "tblMainTbl")) Then
DoCmd.OpenForm "frmMainData"
Else
MsgBox "That is not the correct password. Please enter the correct
password."
End If

This all works fine up to a point.

First need to "Mask" the Input password.
E.G.: Instead of "MyPassword" it should show **********

Second how do You get the Inputbox to prompt 3 times.
E.G.: InputBox WrongPassword then InputBox WrongPassword then InputBox
WrongPassword then MSGBOX "Dbase is Closing"

Have read Microsoft's Supports including "209871 How to Create a Password
Protected Form or Report" but that requires a separate form with it's own
module and the code is long and cumbersome.
Believe the approach described above is a lot simpler and it doesn't
take
up
as much "Real Estate" as Microsoft's solution.

Would someone be so kind as to point me in the correct direction?

Thank You for reading this post.

Andy
 
A

Andy

Hey Rob;

You got me thinking and smiling.

Beliving that since You have learned this; You have also learned how to
overcome it.

Would You be so kind to point me in the correct direction so that I may
overcome this "Obstacle" also?

Andy

Rob Oldfield said:
Nope. It isn't. Go into Access directly (i.e. without double clicking an
mdb or using a shortcut to an mdb), File, Open, hold down the Shift key
while you hit OK and you bypass anything like that.


Andy said:
Rob;

Yes I do know that; so I followed this from Access Help. Is it sufficient?:

If you clear the Use Access Special Keys check box and you specify a custom
menu bar in the Menu Bar box, the built-in menu bar isn't accessible.

If you clear both the Use Access Special Keys check box and the Display
Database Window check box, it's possible that users can still access the
Database window. This can happen when a user tries more than once to open
the same Access database or Access project from the list of
most-recently-used Access databases or Access projects, which automatically
appears on the File menu. To prevent users from accessing this list, replace
the File menu with your own custom menu.

Andy

Andy said:
Hi;

Have created frmPasswordEnter. This frmPasswordEnter opens the first
time
a
User enters the DBase. It is triggered by an If/Then function in the
"AutoExec" macro.
Public Function PasswordPrompt()
Dim strInput As String, strMsg As String

strMsg = "Enter your Password."
strInput = InputBox(Prompt:=strMsg,

If(isnull((DLookup("[Password]", "tblMainTbl") then
DoCmd.OpenForm "frmPasswordEnter"
Else
If strInput Like (DLookup("[Password]", "tblMainTbl")) Then
DoCmd.OpenForm "frmMainData"
Else
MsgBox "That is not the correct password. Please enter the correct
password."
End If

This all works fine up to a point.

First need to "Mask" the Input password.
E.G.: Instead of "MyPassword" it should show **********

Second how do You get the Inputbox to prompt 3 times.
E.G.: InputBox WrongPassword then InputBox WrongPassword then InputBox
WrongPassword then MSGBOX "Dbase is Closing"

Have read Microsoft's Supports including "209871 How to Create a Password
Protected Form or Report" but that requires a separate form with it's own
module and the code is long and cumbersome.
Believe the approach described above is a lot simpler and it doesn't
take
up
as much "Real Estate" as Microsoft's solution.

Would someone be so kind as to point me in the correct direction?

Thank You for reading this post.

Andy
 
A

Andy

Gentlemen;

Believe Rob's point about overriding all code by holding down the Shift key
on Open is valuable and should be learned by all people reading these news
groups.

Posting new question "Stop Shift Key Override On Open MDB".

Andy
 
R

Rob Oldfield

A good place to start: http://www.ltcomputerdesigns.com/Security.htm Make
yourself a large jug of coffee first.

(...the first document only goes up to A2K but I believe that the general
ideas apply if you have later.)

It's not an easy thing to get your head around, but it *is* worth spending
the time on - and the user level security wizard made things a lot easier.
Any other way of doing it, such as those suggestions in this thread, are
little better than a comfort blanket.

One thing that I've seen confuse a lot of people when they start looking at
this - by default, if you connect up to a standard unsecured mdb, then you
do so as a user called Admin. And the first thing that you have to do
therefore, is to remove any serious rights for the Admin user. A very
counter intuitive method I've always thought.


Andy said:
Hey Rob;

You got me thinking and smiling.

Beliving that since You have learned this; You have also learned how to
overcome it.

Would You be so kind to point me in the correct direction so that I may
overcome this "Obstacle" also?

Andy

Rob Oldfield said:
Nope. It isn't. Go into Access directly (i.e. without double clicking an
mdb or using a shortcut to an mdb), File, Open, hold down the Shift key
while you hit OK and you bypass anything like that.


Andy said:
Rob;

Yes I do know that; so I followed this from Access Help. Is it sufficient?:

If you clear the Use Access Special Keys check box and you specify a custom
menu bar in the Menu Bar box, the built-in menu bar isn't accessible.

If you clear both the Use Access Special Keys check box and the Display
Database Window check box, it's possible that users can still access the
Database window. This can happen when a user tries more than once to open
the same Access database or Access project from the list of
most-recently-used Access databases or Access projects, which automatically
appears on the File menu. To prevent users from accessing this list, replace
the File menu with your own custom menu.

Andy

Hi;

Have created frmPasswordEnter. This frmPasswordEnter opens the
first
time
a
User enters the DBase. It is triggered by an If/Then function in the
"AutoExec" macro.
Public Function PasswordPrompt()
Dim strInput As String, strMsg As String

strMsg = "Enter your Password."
strInput = InputBox(Prompt:=strMsg,

If(isnull((DLookup("[Password]", "tblMainTbl") then
DoCmd.OpenForm "frmPasswordEnter"
Else
If strInput Like (DLookup("[Password]", "tblMainTbl")) Then
DoCmd.OpenForm "frmMainData"
Else
MsgBox "That is not the correct password. Please enter the
correct
password."
End If

This all works fine up to a point.

First need to "Mask" the Input password.
E.G.: Instead of "MyPassword" it should show **********

Second how do You get the Inputbox to prompt 3 times.
E.G.: InputBox WrongPassword then InputBox WrongPassword then InputBox
WrongPassword then MSGBOX "Dbase is Closing"

Have read Microsoft's Supports including "209871 How to Create a Password
Protected Form or Report" but that requires a separate form with
it's
own
module and the code is long and cumbersome.
Believe the approach described above is a lot simpler and it doesn't take
up
as much "Real Estate" as Microsoft's solution.

Would someone be so kind as to point me in the correct direction?

Thank You for reading this post.

Andy
 
A

Andy

Rob;

Have learned it is the "Set the AllowBypassKey property to False to disable
the SHIFT key" from Microsoft kb.

However after almost of searching still haven't learned from Microsoft's kb
how to do it.

Andy
 
R

Rob Oldfield

It can be done in an adp...
http://support.microsoft.com/default.aspx?scid=kb;en-us;826765 although
that's about SQL data which is entirely different (i.e. is *really* secure.
MS actually push a warning out that Access cannot guarantee security as it's
just a desktop system)

....and I did find a similar article earlier about mdbs which I can't find
now. Doesn't matter though - lock me out of your mdb using those methods
and I just go to File, Import and import all of your tables and queries.

User level security is the *only* way of doing it.


Andy said:
Rob;

Have learned it is the "Set the AllowBypassKey property to False to disable
the SHIFT key" from Microsoft kb.

However after almost of searching still haven't learned from Microsoft's kb
how to do it.

Andy
Andy said:
Hi;

Have created frmPasswordEnter. This frmPasswordEnter opens the first
time
a
User enters the DBase. It is triggered by an If/Then function in the
"AutoExec" macro.
Public Function PasswordPrompt()
Dim strInput As String, strMsg As String

strMsg = "Enter your Password."
strInput = InputBox(Prompt:=strMsg,

If(isnull((DLookup("[Password]", "tblMainTbl") then
DoCmd.OpenForm "frmPasswordEnter"
Else
If strInput Like (DLookup("[Password]", "tblMainTbl")) Then
DoCmd.OpenForm "frmMainData"
Else
MsgBox "That is not the correct password. Please enter the correct
password."
End If

This all works fine up to a point.

First need to "Mask" the Input password.
E.G.: Instead of "MyPassword" it should show **********

Second how do You get the Inputbox to prompt 3 times.
E.G.: InputBox WrongPassword then InputBox WrongPassword then InputBox
WrongPassword then MSGBOX "Dbase is Closing"

Have read Microsoft's Supports including "209871 How to Create a Password
Protected Form or Report" but that requires a separate form with it's own
module and the code is long and cumbersome.
Believe the approach described above is a lot simpler and it doesn't
take
up
as much "Real Estate" as Microsoft's solution.

Would someone be so kind as to point me in the correct direction?

Thank You for reading this post.

Andy
 
A

Andy

Rob;

In a reply to a post: Stop Shift Key Override On Open MDB

Ricky Hicks sent this answer:

The easiest way to accomplish this is to do it using a remote app designed
to
do this.

See the Utility at the link below:
http://www.utteraccess.com/forums/showthreaded.php?Cat=&Board=48&Number=233728

Adding Your answer RE: ADP.

To the reply from him.

Andy

Rob Oldfield said:
It can be done in an adp...
http://support.microsoft.com/default.aspx?scid=kb;en-us;826765 although
that's about SQL data which is entirely different (i.e. is *really* secure.
MS actually push a warning out that Access cannot guarantee security as it's
just a desktop system)

...and I did find a similar article earlier about mdbs which I can't find
now. Doesn't matter though - lock me out of your mdb using those methods
and I just go to File, Import and import all of your tables and queries.

User level security is the *only* way of doing it.


Andy said:
Rob;

Have learned it is the "Set the AllowBypassKey property to False to disable
the SHIFT key" from Microsoft kb.

However after almost of searching still haven't learned from Microsoft's kb
how to do it.

Andy
Andy said:
Hi;

Have created frmPasswordEnter. This frmPasswordEnter opens the first
time
a
User enters the DBase. It is triggered by an If/Then function in the
"AutoExec" macro.
Public Function PasswordPrompt()
Dim strInput As String, strMsg As String

strMsg = "Enter your Password."
strInput = InputBox(Prompt:=strMsg,

If(isnull((DLookup("[Password]", "tblMainTbl") then
DoCmd.OpenForm "frmPasswordEnter"
Else
If strInput Like (DLookup("[Password]", "tblMainTbl")) Then
DoCmd.OpenForm "frmMainData"
Else
MsgBox "That is not the correct password. Please enter the correct
password."
End If

This all works fine up to a point.

First need to "Mask" the Input password.
E.G.: Instead of "MyPassword" it should show **********

Second how do You get the Inputbox to prompt 3 times.
E.G.: InputBox WrongPassword then InputBox WrongPassword then InputBox
WrongPassword then MSGBOX "Dbase is Closing"

Have read Microsoft's Supports including "209871 How to Create a Password
Protected Form or Report" but that requires a separate form with it's own
module and the code is long and cumbersome.
Believe the approach described above is a lot simpler and it doesn't
take
up
as much "Real Estate" as Microsoft's solution.

Would someone be so kind as to point me in the correct direction?

Thank You for reading this post.

Andy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top