Focus after DblClick

K

Keith

I would like to open a form and set the focus to a particular control on that
form by double-clicking on a particular textbox on another form. The
following code, when put in the click event of a button, does the job just
fine. However, the same code in the double click event of a textbox, opens
the form as expected but leaves the focus (or returns focus) on the textbox
that was double-clicked.

Code:

DoCmd.OpenForm "frmStockLocation", acNormal, , "[JOB_NO]=" & Chr(34) &
Me.Job_Number & Chr(34)

Note that the on load event of the newly opened form includes the
appropriate code to set the focus to the correct control. My problem is
really just keeping focus on the newly opened form...I think.

Thanks,

Keith
 
A

Arvin Meyer [MVP]

Add the line:

[Forms]![frmStockLocation]![TextboxNameYou Want].SetFocus

after the Open form line.
 
K

Keith

Arvin,

Thank you for the response. I tried what you suggested, but I got the same
results. Following is the code in the DblClick event:

DoCmd.OpenForm "frmStockLocation", acNormal, , "[JOB_NO]=" & Chr(34) &_
Me.Job_Number & Chr(34)
[Forms]![frmstocklocation]![stock location].SetFocus

Do you have any other ideas why the focus isn't staying with the newly
opened form?

Thanks,

Keith


Arvin Meyer said:
Add the line:

[Forms]![frmStockLocation]![TextboxNameYou Want].SetFocus

after the Open form line.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com


Keith said:
I would like to open a form and set the focus to a particular control on
that
form by double-clicking on a particular textbox on another form. The
following code, when put in the click event of a button, does the job just
fine. However, the same code in the double click event of a textbox,
opens
the form as expected but leaves the focus (or returns focus) on the
textbox
that was double-clicked.

Code:

DoCmd.OpenForm "frmStockLocation", acNormal, , "[JOB_NO]=" & Chr(34) &
Me.Job_Number & Chr(34)

Note that the on load event of the newly opened form includes the
appropriate code to set the focus to the correct control. My problem is
really just keeping focus on the newly opened form...I think.

Thanks,

Keith
 
D

Dirk Goldgar

Keith said:
I would like to open a form and set the focus to a particular control on
that
form by double-clicking on a particular textbox on another form. The
following code, when put in the click event of a button, does the job just
fine. However, the same code in the double click event of a textbox,
opens
the form as expected but leaves the focus (or returns focus) on the
textbox
that was double-clicked.

Code:

DoCmd.OpenForm "frmStockLocation", acNormal, , "[JOB_NO]=" & Chr(34) &
Me.Job_Number & Chr(34)

Note that the on load event of the newly opened form includes the
appropriate code to set the focus to the correct control. My problem is
really just keeping focus on the newly opened form...I think.

I'm not observing this behavior. Do you have any code in the Click event of
the text box? The Click event will fire before the DblClick event.
 
A

Arvin Meyer [MVP]

The only reason that it might not work is that you have other code running
after it which takes the focus either back to the calling form, or there's
code on the called form in the Open, Load, or Current event which interferes
with this code.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com


Keith said:
Arvin,

Thank you for the response. I tried what you suggested, but I got the
same
results. Following is the code in the DblClick event:

DoCmd.OpenForm "frmStockLocation", acNormal, , "[JOB_NO]=" & Chr(34) &_
Me.Job_Number & Chr(34)
[Forms]![frmstocklocation]![stock location].SetFocus

Do you have any other ideas why the focus isn't staying with the newly
opened form?

Thanks,

Keith


Arvin Meyer said:
Add the line:

[Forms]![frmStockLocation]![TextboxNameYou Want].SetFocus

after the Open form line.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com


Keith said:
I would like to open a form and set the focus to a particular control on
that
form by double-clicking on a particular textbox on another form. The
following code, when put in the click event of a button, does the job
just
fine. However, the same code in the double click event of a textbox,
opens
the form as expected but leaves the focus (or returns focus) on the
textbox
that was double-clicked.

Code:

DoCmd.OpenForm "frmStockLocation", acNormal, , "[JOB_NO]=" & Chr(34) &
Me.Job_Number & Chr(34)

Note that the on load event of the newly opened form includes the
appropriate code to set the focus to the correct control. My problem
is
really just keeping focus on the newly opened form...I think.

Thanks,

Keith
 

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