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 Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

password protect a single field on a form 2

Status
Not open for further replies.

dutchie25

Technical User
Mar 8, 2002
2
US
Is there an easy way to password protect a single text box on a form? The person wants to be able to protect the text box that his department enters info into. He does not want anyone else to be able to change what he has entered.

Thanks for any help you can give me.
 
Sure can... use the Enable/Locked options. I assume that you have a login page where you capture User Name and User Access? If so, you can simply check what the user level is and enable/disable or lock fields accrodingly on certain screens. My approach is to store the User Name and User Level on the main menu as a hidden field that I can then reference as needed.

On the Form Load event, you can set the properties for fields as needed. If the form is non-modal, you may want to have that code in the Activate event.

htwh, Steve Medvid
"IT Consultant & Web Master"
 
Hi!

One way would be to set the enable property to false. Delete the label attached to the text box and add a command button to take its place, i.e. the command will also serve as the label for the text box. Alternatively, you could just add a command button, if the form has enough room for it. In the click event for the command button use the following code:

Dim strPassword As String

strPassword = InputBox("Please enter the password: ")
If strPassword = "YourPassword" Then
Me!txtTextBox.Enabled = True
Else
Call MsgBox("The password you entered was incorrect")
End If

If you want to hide the password as it is entered then you will need to use popup form instead of the InputBox. In the LostFocus event of the text box use:

Me!txtTextBox.Enabled = False

hth
Jeff Bridgham
bridgham@purdue.edu
 
Thanks guys. I am an Accountant who knows some about Access and will be using it with my new job. I looked in the book I have and could not find anything. I know a little VBA programming from a class but have not used it in a while.

Thanks for your help, I can't believe the quick response I got.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top