Notification (Msgbox) for locked controls

  • Thread starter Aad via AccessMonster.com
  • Start date
A

Aad via AccessMonster.com

Hi there,

Except in case of a new record, I have the controls on my forms locked to
prevent accidentally editing.
The user must click a button to unlock all controls at once and will then be
able to edit the data.

This works fine. However, it is not always clear to users that the controls
are locked at first.
I would like to have a msgbox that will show up only when someone tries to
editing the locked controls.
In that way the user will be noted to click the unlock button first.

It is not neccesarry that the msgbox has a unlock button in it since it's
already on the form.

Please help.

Aad.
 
A

Allen Browne

Use the KeyPress event of the control to MsgBox.
It still fires even if the control is locked.

There are other ways to give the user a visual cue that the form is locked.
My preferred approach is to display a red rectangle around the locked form.
It's quite obvious. Screenshot and example:
Locking bound controls on a form and subforms
at:
http://allenbrowne.com/ser-56.html
 
R

ro via AccessMonster.com

Thank you for your quick response.

Can you give an code example of the KeyPress event and how to detect the
(lock) status of the controls?
Again, in case of a new record they aren't locked.

Thanks, Aad




Allen said:
Use the KeyPress event of the control to MsgBox.
It still fires even if the control is locked.

There are other ways to give the user a visual cue that the form is locked.
My preferred approach is to display a red rectangle around the locked form.
It's quite obvious. Screenshot and example:
Locking bound controls on a form and subforms
at:
http://allenbrowne.com/ser-56.html
Except in case of a new record, I have the controls on my forms locked to
prevent accidentally editing.
[quoted text clipped - 15 lines]
 
A

Allen Browne

Use the KeyPress event of the control.

If it fires, somebody tried to type into the control.

If the controls' Locked property is True, then it's locked.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.
ro via AccessMonster.com said:
Thank you for your quick response.

Can you give an code example of the KeyPress event and how to detect the
(lock) status of the controls?
Again, in case of a new record they aren't locked.

Thanks, Aad




Allen said:
Use the KeyPress event of the control to MsgBox.
It still fires even if the control is locked.

There are other ways to give the user a visual cue that the form is
locked.
My preferred approach is to display a red rectangle around the locked
form.
It's quite obvious. Screenshot and example:
Locking bound controls on a form and subforms
at:
http://allenbrowne.com/ser-56.html
Except in case of a new record, I have the controls on my forms locked
to
prevent accidentally editing.
[quoted text clipped - 15 lines]
 
R

ro via AccessMonster.com

Okay, I got it working here.
But even when the control is unlocked it fires the event.
It should only show up when it is locked and someone type into the control.

Thank you



Allen said:
Use the KeyPress event of the control.

If it fires, somebody tried to type into the control.

If the controls' Locked property is True, then it's locked.
Thank you for your quick response.
[quoted text clipped - 22 lines]
 
A

Allen Browne

You will therefore need to use an If statement, and test the Locked
property.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

ro via AccessMonster.com said:
Okay, I got it working here.
But even when the control is unlocked it fires the event.
It should only show up when it is locked and someone type into the
control.

Thank you



Allen said:
Use the KeyPress event of the control.

If it fires, somebody tried to type into the control.

If the controls' Locked property is True, then it's locked.
Thank you for your quick response.
[quoted text clipped - 22 lines]
 
R

ro via AccessMonster.com

Hi,
I got it working with the following code:

Private Sub reject_ref_KeyPress(KeyAscii As Integer)
If Me.reject_ref.Locked Then
MsgBox "Data is Locked.", vbInformation, ":: Data is Locked ::"
Else
End If
End Sub

However, instead of adding this code to each of the controls KeyPress events
I think it should be possible to create a more generic way to do this.

Thanks



Allen said:
You will therefore need to use an If statement, and test the Locked
property.
Okay, I got it working here.
But even when the control is unlocked it fires the event.
[quoted text clipped - 14 lines]
 
A

Allen Browne

Perhaps you could set the form's KeyPreview to Yes, and use its KeyPress
event.

If some controls are locked and others not, you might be able to test the
Locked property of Me.ActiveControl

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

ro via AccessMonster.com said:
Hi,
I got it working with the following code:

Private Sub reject_ref_KeyPress(KeyAscii As Integer)
If Me.reject_ref.Locked Then
MsgBox "Data is Locked.", vbInformation, ":: Data is Locked ::"
Else
End If
End Sub

However, instead of adding this code to each of the controls KeyPress
events
I think it should be possible to create a more generic way to do this.

Thanks



Allen said:
You will therefore need to use an If statement, and test the Locked
property.
Okay, I got it working here.
But even when the control is unlocked it fires the event.
[quoted text clipped - 14 lines]
 

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