Set the form's KeyPreview on, and use its KeyDown event.
This could be really confusing for the user though, if the Enter key has 3
different behaviors:
- move field;
- move record;
- create a new line in a (memo) field.
If you proceed anyway, you will need to consider how this event could
interact with other events that must occur before the current edits are
saved and the form can move record. For example, if the user is in a text
box when they press enter, it will trigger:
- the form's Error event if a table-level validation rule is not met or the
data type is invalid,
- the control's events, such as Change, Before Update, Exit, and Lost Focus;
- the form's Before Update event, which precedes the saving of the record
There could be problems at any of those levels.
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Reply to group, rather than allenbrowne at mvps dot org.
KarstenTech said:
I want to change the default behavior of the enter key depending upon
which form is currently displayed. On one form I want it to move to the
next field, on another I want it to move to the next record. Ideas?