G
Gary D.
Help - I'm getting in a muddle!
In Access2003, I have a popup modal form with the following:
one unbound text box into which is typed a security code with no events coded
one command button "btn_CloseForm_Click" with just the OnClick event coded
(and another command button that is not relevant to the current problem)
Within the "btn_CloseForm_Click" event a sub procedure (let's call it "X") is
called that performs some simple processing, after which control passes back
to "btn_CloseForm_Click" and then a "DoCmd.Close acForm, strCurrentForm.Name"
command is issued to close the form.
It is important to mention that procedure "X" needs to be called twice, once
for the first entry of the security code and then later on a second time for
re-entry and verification of the security code. The second call happens at a
different stage within the application but using this same form.
Here is the problem . . .
A present, when using the keyboard, when a user types a value into the text
box and presses the enter key, the cursor moves to the next tab stop, which is
the command button and the user must then hit the enter key again to trigger
the "btn_CloseForm_Click" event. That is working just fine.
Ideally I would like the keyboard behaviour to operate differently, such that
after a user types a value into the text box and presses the enter key, I can
capture that sequence of events and invoke procedure "X" (once only) and then
close the form, so the user doesn't have to hit the enter key again once the
cursor has moved onto the command button.
However, procedure "X" gets called twice (because of the way Access events
work?) and this is causing my coding to work differently from intended.
I appreciate that this description probably isn't very clear, but hope it
makes some sense.
So, how can I achieve my intended keyboard behaviour?
In Access2003, I have a popup modal form with the following:
one unbound text box into which is typed a security code with no events coded
one command button "btn_CloseForm_Click" with just the OnClick event coded
(and another command button that is not relevant to the current problem)
Within the "btn_CloseForm_Click" event a sub procedure (let's call it "X") is
called that performs some simple processing, after which control passes back
to "btn_CloseForm_Click" and then a "DoCmd.Close acForm, strCurrentForm.Name"
command is issued to close the form.
It is important to mention that procedure "X" needs to be called twice, once
for the first entry of the security code and then later on a second time for
re-entry and verification of the security code. The second call happens at a
different stage within the application but using this same form.
Here is the problem . . .
A present, when using the keyboard, when a user types a value into the text
box and presses the enter key, the cursor moves to the next tab stop, which is
the command button and the user must then hit the enter key again to trigger
the "btn_CloseForm_Click" event. That is working just fine.
Ideally I would like the keyboard behaviour to operate differently, such that
after a user types a value into the text box and presses the enter key, I can
capture that sequence of events and invoke procedure "X" (once only) and then
close the form, so the user doesn't have to hit the enter key again once the
cursor has moved onto the command button.
However, procedure "X" gets called twice (because of the way Access events
work?) and this is causing my coding to work differently from intended.
I appreciate that this description probably isn't very clear, but hope it
makes some sense.
So, how can I achieve my intended keyboard behaviour?