• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 817
  • Last Modified:

Set focus to a form after closing sub form

I have a popup modal form that incorporates a subform used to search records. Once a record is clicked on the subform, the subform filters a form called frm_LoanClosing. Then the code in the subform closes the main form that the subform resides in. At that point, I'm trying to set the focus back to a control on frm_LoanClosing. I have the following in the On Close event of the main form that holds the subform:

Forms!frm_LoanClosing.Controls!cmbApplicationNumber.SetFocus

However, not only does the focus not land on the cmbApplicatonNumber control, it doesn't even land on the frm_LoanClosing form.

I have attached an example MDB with the forms.
Example.mdb
0
BradleyOnTheRoad
Asked:
BradleyOnTheRoad
1 Solution
 
Rey Obrero (Capricorn1)Commented:
Forms!frm_LoanClosing.SetFocus
Forms!frm_LoanClosing.cmbApplicationNumber.SetFocus
0
 
BradleyOnTheRoadAuthor Commented:
That didn't work. Maybe I'm calling it from the wrong form or event?
0
 
dannywarehamCommented:
You can't set focus to a form - it has to be to a control on the form (as cap suggests)

This may also help:
http://www.mvps.org/access/forms/frm0031.htm
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
BradleyOnTheRoadAuthor Commented:
I'm confused because I am able to change he value of the control with
 Forms!frm_LoanClosing.Controls!cmbApplicationNumber = Me.txtloan_ID
But I can't set the focus to the control as well. I must be causing a conflict with another spot in my code.
0
 
irudykCommented:
Try changing the line of code to:
    Form_frm_LoanClosing.cmbApplicationNumber.SetFocus
0
 
dannywarehamCommented:
Isthe control enabledlocked?

You can change the value in code, but not actually select it if this is the case
0
 
BradleyOnTheRoadAuthor Commented:
Yes, that was the answer. My code disabled the control for other reasons before I tried to set the focus.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now