Lock field with a check box

pwicr

Registered User.
Local time
Today, 02:15
Joined
Sep 22, 2011
Messages
144
I have created a check box that I want to use that if checked it locks only a certain field. I enter vehicle vin numbers and want to avoid accidental deletion but want to allow for quick editing and need the ability to add new records. Can you help me with the code?
 
I have used the following code.

Me.YourTextBoxNameHere.Locked = Not (Me.YourCheckBoxNameHere)

Problem is, it lock it when the box is UNchecked. It's backwards!!!

HELP!
 
Is your form in Single Form view?
 
I think so. there is only one form, mutiple tabs.
 
Ok, so all you do is remove the NOT part so it reads:
Code:
Me.YourTextBoxNameHere.Locked = Nz (Me.YourCheckBoxNameHere, 0)
 
You're welcome!

Just one more question. What events did you put the code?
 
This would be useful to me actually, which event would you expect it to be placed in, vbaInet?
 
In the After Update event of the checkbox and in the Current event of the form.
 
vbaInet:

I put it in the after update event

I've encountered an issue though.

When I check/uncheck the check box, it checks/unchecks ALL the records, not just the one I'm on. Also, when I go back into my database, I have to check the box again each time. Even if I just go from design view to form view.
 
That's because your checkbox is unbound. Plus I asked in my first post whether the form is a Single Form and you said yes but what you've just described is the sort of behaviour you see in a Continuous Form or Datasheet.
 
this is what it looks like
 

Attachments

  • LOCK FIELD.png
    LOCK FIELD.png
    17.3 KB · Views: 112
A bound control is one that has its Control Source set to one of the fields in the form's Record Source.
 
I understand that but when I create a check box I don't see where to make it "bound" to a field.
 
Look through all the tabs. The obvious tab is the Data tab where you will find the Control Source property of the checkbox.
 
What vbaInet is asking is "Does the record source of your Form include the "checkbox" field?"

????Again vabInet has responded while Iwas typing. I must just be typing too slow.
 
What vbaInet is asking is "Does the record source of your Form include the "checkbox" field?"
I'm thinking he's not set the Control Source of that checkbox yet hence, the behaviour.
 

Users who are viewing this thread

Back
Top Bottom