How to prevent accidental field changes

I

Iram

Hello.
I have a "Data Entry" form with a few fields. The fields are "List Boxes".
It is so easy to change your selection in the list box by accident. How can
I prevent accidental changes. I would like to configure it so that if someone
wanted to modify a list box they would have to hold down Cntrl before
clicking on the field to change it or double clicking the list box to change
it.

Could you help me with the correct vba or anything else to make this
possible? Btw, do you recommend the Cntrl button/click or double clicking
method to change a field?

Thanks.

Iram/mcp
 
R

Rick Brandt

Iram said:
Hello.
I have a "Data Entry" form with a few fields. The fields are "List
Boxes". It is so easy to change your selection in the list box by
accident. How can I prevent accidental changes. I would like to
configure it so that if someone wanted to modify a list box they
would have to hold down Cntrl before clicking on the field to change
it or double clicking the list box to change it.

Could you help me with the correct vba or anything else to make this
possible? Btw, do you recommend the Cntrl button/click or double
clicking method to change a field?

Thanks.

Iram/mcp

Easiest would be to set form properties...

AllowDeletions = False
AllowEdits = False

....and then provide an [ Edit ] button that changes those properties. Then
the user has to press that button before a record can be changed.
 
I

Iram

I have the below three fields that I want to protect from accidental changes
Case#
Reason
Person Calling

How do I type the vba code for each button "On Click" event to unlock each
field?
I would also like the wording on the button to change from "Edit Case#" to
"Lock" so that when they are done editing the field they can click "Lock" to
prevent any changes after.
Would you know how to do this too?



Iram/mcp

Rick Brandt said:
Iram said:
Hello.
I have a "Data Entry" form with a few fields. The fields are "List
Boxes". It is so easy to change your selection in the list box by
accident. How can I prevent accidental changes. I would like to
configure it so that if someone wanted to modify a list box they
would have to hold down Cntrl before clicking on the field to change
it or double clicking the list box to change it.

Could you help me with the correct vba or anything else to make this
possible? Btw, do you recommend the Cntrl button/click or double
clicking method to change a field?

Thanks.

Iram/mcp

Easiest would be to set form properties...

AllowDeletions = False
AllowEdits = False

....and then provide an [ Edit ] button that changes those properties. Then
the user has to press that button before a record can be changed.
 
D

Douglas J. Steele

Lock the list box(es) in the form's Current event:

Private Sub Form_Current()
Me.List0.Locked = True
End Sub

You can put the logic to unlock them in the double click event:

Private Sub List0_DblClick(Cancel As Integer)
Me.List0.Locked = False
End Sub

or you can toggle the Locked property:

Private Sub List0_DblClick(Cancel As Integer)
Me.List0.Locked = Not Me.List0.Locked
End Sub

You could use a command button, but it takes up more space that you might be
able to better use.
 
I

Iram

Douglas,

That worked very nicely.
How do I lock the same field after I am done editing it?
With the code you gave me the field unlocks but stays unlocked when I go to
a different field.

Iram/mcp
 
D

Douglas J. Steele

You can use the LostFocus event:

Private Sub List0_LostFocus()
Me.List0.Locked = True
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top