Locking control after value is changed from it's default value

baadams

Board Regular
Joined
Mar 2, 2006
Messages
134
I want to lock a control after it's been changed from it's default value. Not allowing any additional changes unless a password is supplied. Locking or password protecting the control will work. Is there a way to check the value when the control has focus to check for the default value, then prompt for a password if the value does not equal the default value? I can handle the code to prompt for the password, I'm curious as to what event to use.
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
I figured it out..........

I used the Got Focus event to perform the following.


If not(isnull(me.field)) then
msg = MsgBox("This field can't be changed from it's original value", vOKOnly)
field2.SetFocus
End If

So once the value has been input it can't be changed. I haven't added the password code to set the focus back to the selected field if a change is allowed.
This solution just sees the value isn't null and changes the focus to a different field so the user doesn't have the chance to make any changes. I didn't need to set a default value.
 
Upvote 0

Forum statistics

Threads
1,224,579
Messages
6,179,656
Members
452,934
Latest member
mm1t1

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top