Solved

Set focus to a form after closing sub form

Posted on 2008-10-12
7
807 Views
Last Modified: 2013-11-28
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
Comment
Question by:BradleyOnTheRoad
7 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 22698236
Forms!frm_LoanClosing.SetFocus
Forms!frm_LoanClosing.cmbApplicationNumber.SetFocus
0
 

Author Comment

by:BradleyOnTheRoad
ID: 22698275
That didn't work. Maybe I'm calling it from the wrong form or event?
0
 
LVL 26

Expert Comment

by:dannywareham
ID: 22699104
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
Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 

Author Comment

by:BradleyOnTheRoad
ID: 22699340
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
 
LVL 23

Expert Comment

by:irudyk
ID: 22700081
Try changing the line of code to:
    Form_frm_LoanClosing.cmbApplicationNumber.SetFocus
0
 
LVL 26

Accepted Solution

by:
dannywareham earned 500 total points
ID: 22701112
Isthe control enabledlocked?

You can change the value in code, but not actually select it if this is the case
0
 

Author Closing Comment

by:BradleyOnTheRoad
ID: 31505467
Yes, that was the answer. My code disabled the control for other reasons before I tried to set the focus.
0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Access 2016 - query 23 56
Reference theme colors in VBA 4 23
Obtaining Access 2013 Runtime file for Sagekey 2013 Installer 3 17
Reference Controls on subforms 7 25
QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

816 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now