Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB password script for access database 2

Status
Not open for further replies.

joe2kuk

Technical User
Oct 14, 2002
29
GB
Here is a code Im using for a password for but when the password is entered it is displayed as you type it not as "******" any one know how I can edit it so it dosnt show the password?

Function callit()
Call password
End Function
Sub password()
Dim password, messages, titles
messages = "Please enter password"
titles = "Password"
password = InputBox(messages, titles)
If password = "nurse" Then DoCmd.OpenForm "nurses" Else If password = "doctor" Then DoCmd.OpenForm "docs" Else If password = "clerk" Then DoCmd.OpenForm "clearks" Else DoCmd.OpenForm "startup"
End Sub


Thanks for your help........:)
 
Use a Textbox control and set it's PasswordChar property to '*' like this:

text1.PasswordChar = "*"

If you want this to look like an inputbox control use it on a form on its own and open it as modal
________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'People who live in windowed environments shouldn't cast pointers.'
 
johnwm has correctly answer the question. I just wanted to make a suggestion with respect to style.

Rather than using a cascading If-Then-Else statement
if password = "nurse" Then DoCmd.OpenForm "nurses" Else If password = "doctor" Then DoCmd.OpenForm "docs" Else If password = "clerk" Then DoCmd.OpenForm "clearks" Else DoCmd.OpenForm "startup"
I would suggest that you take a look at the Case statement
Select Case password
Case "nurse"
DoCmd.OpenForm "nurses"
Case "doctor"
DoCmd.OpenForm "docs"
Case "clerk"
DoCmd.OpenForm "clearks" ' Type ???
Case Else
DoCmd.OpenForm "startup"
End Select



Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top