AllowEdits disabled event

  • Thread starter Thread starter Ed Finley
  • Start date Start date
E

Ed Finley

I have a form which sets allowedits to false on locked records. Is there en
event triggered when someone tries to update a locked field? I'm trying to
get a message box to appear.
Thanks,
Ed
 
I don't have Access here to check, but I think that the key- and mouse-
events will occur for the locked control.

Try setting the form's KeyPreview property to True, and add a KeyPress event
for one of the locked controls. See if that fires.

The "change" events (BeforeUpdate, AfterUpdate etc.) will not fire for a
locked control (for the obvious reason).

HTH,
TC
 
In your Keydown event, check the AllowEdits property:

If Me.AllowEdits = False Then
msgbox "Can't update - this reord is locked"
end if
 
He'd want to limit the msg based on the key, though. For example, he would
not want the msg if he pressed End (or whatever) to go to the end of the
field, or if he tabbed to the next field :-)

TC
 
Thanks for the responses. The form can be updated with either a key or the
mouse (for the combo boxes). I would like to be able to key or mouse to the
next record without a warning. I'm thinking I could set every control's key
or mouse event to what Scott recommended. How would I set the form Keydown
event to look only for the tab key?
Ed
 
Ed, you will find various surprises awaiting you here!

For example, when you tab from control 'A' to control 'B', the tab keypress
event occurs for control 'B' - not control 'A'!

My point in commenting on the previous post, is that most (but not all) of
the keys that activate the keypress event, will attempt to update the
control. Whereas *all* keys activate the keydown event, and many of those
*do not* try to update the control. So if you are looking for "updating"
keystrokes, it may be easier to do this in KeyPress rather than KeyDown.

But to complicate that, there is one "updating" key (Del? - I don't have
Access here to check) which fires KeyDown, but not KeyPress!

So you will probably need to do a fair bit of experimenting to get what you
want.

HTH,
TC
 
Back
Top