'On Exit' working for tab-key but not for mouse

  • Thread starter SimonG via AccessMonster.com
  • Start date
S

SimonG via AccessMonster.com

On a continuous form, a control in detail section of form, uses the 'On Exit'
property. The 'On Exit' event triggers serial actions (functions) including
setting values within other controls and writing/updating record(s).

When the user uses the keyboard to exit the control (tab-key) the functions
all complete correctly and the focus moves to the next control. However if
the user uses the mouse, the outcome is unexpected; although the functions
always complete correctly, moving to the control clicked does not always
happen.
Results of mouse exits:
moving within same record to a unfilled (empty) control, focus moves as
expected (to selected control);
moving within same record to a populated control, focus stays in original
control;
moving to new record, populated or empty control, focus stays in original
control.

What could be occurring that is preventing the focus from moving to where the
mouse clicks?


Regards,
Simon
 
M

Marshall Barton

SimonG said:
On a continuous form, a control in detail section of form, uses the 'On Exit'
property. The 'On Exit' event triggers serial actions (functions) including
setting values within other controls and writing/updating record(s).

When the user uses the keyboard to exit the control (tab-key) the functions
all complete correctly and the focus moves to the next control. However if
the user uses the mouse, the outcome is unexpected; although the functions
always complete correctly, moving to the control clicked does not always
happen.
Results of mouse exits:
moving within same record to a unfilled (empty) control, focus moves as
expected (to selected control);
moving within same record to a populated control, focus stays in original
control;
moving to new record, populated or empty control, focus stays in original
control.

What could be occurring that is preventing the focus from moving to where the
mouse clicks?


It sounds like your code somehow cancelling the exit event
ot maybe it's (re)setting the focus in some situation.
 
L

Linq Adams via AccessMonster.com

What exactly is being done and what type of control is this OnExit event?
Truth be, OnExit is seldom used by experienced developers. The AfterUpdate
event is more commonly used to trigger something when a control is exited.
 
S

SimonG via AccessMonster.com

Marshall and Linq,

Sorry for the slow response, I have been experimenting with the change
suggested by Linq, which I believe will work for my form.


Marshall said:
It sounds like your code somehow cancelling the exit event
or maybe it's (re)setting the focus in some situation.

Marshall,

That's what I thought, but after following the code through debug, it is not
running a set focus anywhere. Also, running similar changes with both
keyboard and mouse, the focus only sticks when using the mouse. Does anyone
know, is there an Access command that is likely to reset/or cancel a focus
change (and only for mouse operation)?

Linq Adams wrote:
What exactly is being done and what type of control is this OnExit event?
Truth be, OnExit is seldom used by experienced developers. The AfterUpdate
event is more commonly used to trigger something when a control is exited.

Linq,

The control is a text-box, formatted to except a time (date) value.

The control is the last of a group of three, which need to be completed and
recorded.
The type of data being recorded effects which of this group must be completed.
The remaining controls are populated with default/derived values.
The parameters effecting the type of record, and hence the defaults which can
used, are set in the form-header.
This gave the opportunity to make data entry easier for the user, as only one
(possibly two) results need to be entered.
Code attached to the OnExit event works with the completed values, and the
header parameters, to determine which records, if any, required writing or
updating, and run the SQL to to do this.
Any default values assigned are returned to the appropriate form controls.

OnExit was originally used, as the code will trigger from the last control
regardless of whether its value has been changed or not. This worked well
when the form was being driven by keyboard alone.

I am now revising the form to allow for mouse use. The first issue
encountered was a difference in behaviour between mouse and keyboard (hence
my post, as I could find others requiring focus not to move, but none with
the mouse/keyboard discrepancy I am experiencing, where the focus wasn't
moving).

Changing the control event from OnExit to AfterUpdate works well for both
keyboard and mouse, giving only the expected movements of focus.
This change does require some additional code, but not as much as I was
expecting to cope with the erratic mouse (non-)movements.
To allow for the user not completing all controls within a group,
AfterUpdate has also been added to each of the controls within the groups,
again not much extra code.
As an additional bonus, having the additional code on all the controls, also
cures the next (expected) problem, of dealing with erratic user entry,
possible with a mouse, where the user isn't forced into the linear control-by-
control sequence enforced by keyboard use.


Many thanks Marshall and Linq,
Regards,
Simon
 

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