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

How to lock field after data has been entered. 1

Status
Not open for further replies.

davecarson

Programmer
Nov 14, 2000
12
US
How can a I protect a field after data is entered into it the first time, and then require a password to change the data?

Thanks
Dave
 
If the name of the field is PROTECTED_FIELD then you could do something like this...

Private Sub PROTECTED_FIELD_Exit(Cancel As Integer)
dim pwd as string

if me.PROTECTED_FIELD <> me.PROTECTED_FIELD.old_value then
pwd = InputBox(&quot;You must enter a password to change this field value:&quot;, &quot;Password&quot;)

if pwd <> &quot;Please&quot; then
cancel = true
endif
endif
End Sub
 
Thanks ! it worked except I have to take the underscore off of the old_value so it looks like this:

me.PROTECTED_FIELD.Oldvalue
 
Serves me right for doing it off the top of my head!!! Sorry about that. Glad you figured it out.

BTW If security is a concern you may also want to consider masking the password. I do not believe the InputBox allows you to do this. I have done so by creating a form that contains a single unbound textbox whose input mask is Password. You can then build the appropriate code to return the value entered back to the calling form for validation...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top