M
Mark P
I'm trying to close a form as part of the on exit event of a control
on the form, and receiving 2585 - can't close when processing form or
report errors. Attempting to work around this, I have tried the
following:
1) Setting the focus to a dummy command button in the last line of the
onexit code, and then using the btnclick routine to close the form.
I've tried both calling the btnclick routine directly (when the
routine runs, but still gives 2585 errors) from the btnonenter code,
and sendkeys({ENTER}),[tried both TRUE and FALSE] from the btnonetner
code, when the btnclick code doesn't even run (which I don't
understand - form keypreview is on, but the formkeydown event, which
just sets a flag, doesn't run either, and I thought key events did
pass through to the controls after the form anyway). I tried to use
the btnkeypress event instead of the btnclick event, but that didn't
fire either. I've also tried both these methods from the btngotfocus
code, with the same unsuccessful outcomes.
2) Setting the focus to a dummy text box in the last line of the
onexit code, changing the value of the txtbox in its ongotfocus (also
tried onenter) code, and then trying to close the form from the txtbox
beforeupdate (also tried afterupdate and onchange) code, which didn't
work as those events didn't fire, even when I tried
sendkeys("{ENTER}"),[again tried with both TRUE and FALSE] after
changing the txtbox value.
One key point about all these problems is that once the code on the
dummy button or txtbox has run, stepping through the code always takes
one back to the original control onexit code - even though the only
remaining line is exit sub, and the focus should have passed already.
Is this the problem? When does the onexit event actually finish?
I seem to have a separate problem in that Sendkeys doesn't seem to
work.
Any solutions or workarounds gladly received, except suggesting that I
put this code in the before or afterupdate event of the original
control: this control is key to the functioning of the form, and
often has it's value modified by other code, but I need the onenter
event of the code to fire before the onexit event, and to control the
occurence of these events independently of the value of the control
changing.
Thanks
on the form, and receiving 2585 - can't close when processing form or
report errors. Attempting to work around this, I have tried the
following:
1) Setting the focus to a dummy command button in the last line of the
onexit code, and then using the btnclick routine to close the form.
I've tried both calling the btnclick routine directly (when the
routine runs, but still gives 2585 errors) from the btnonenter code,
and sendkeys({ENTER}),[tried both TRUE and FALSE] from the btnonetner
code, when the btnclick code doesn't even run (which I don't
understand - form keypreview is on, but the formkeydown event, which
just sets a flag, doesn't run either, and I thought key events did
pass through to the controls after the form anyway). I tried to use
the btnkeypress event instead of the btnclick event, but that didn't
fire either. I've also tried both these methods from the btngotfocus
code, with the same unsuccessful outcomes.
2) Setting the focus to a dummy text box in the last line of the
onexit code, changing the value of the txtbox in its ongotfocus (also
tried onenter) code, and then trying to close the form from the txtbox
beforeupdate (also tried afterupdate and onchange) code, which didn't
work as those events didn't fire, even when I tried
sendkeys("{ENTER}"),[again tried with both TRUE and FALSE] after
changing the txtbox value.
One key point about all these problems is that once the code on the
dummy button or txtbox has run, stepping through the code always takes
one back to the original control onexit code - even though the only
remaining line is exit sub, and the focus should have passed already.
Is this the problem? When does the onexit event actually finish?
I seem to have a separate problem in that Sendkeys doesn't seem to
work.
Any solutions or workarounds gladly received, except suggesting that I
put this code in the before or afterupdate event of the original
control: this control is key to the functioning of the form, and
often has it's value modified by other code, but I need the onenter
event of the code to fire before the onexit event, and to control the
occurence of these events independently of the value of the control
changing.
Thanks