Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...Really appreciate your site. Really good site for learning what others do when they run into problems. You guy's are great!!!..."

Geography

Where in the world do Tek-Tips members come from?

Move from a control in a subform to a control in the main formHelpful Member!(2) 

CVesta81 (TechnicalUser)
10 Aug 12 12:25
Hello,

I have a main form with a subform in it. The main form's name is frm1ASalesOrders and the subform's name is frmA3SalesOrderDetail. I am trying to program a Lost Focus event so that when the last control in the subform loses its focus, the control RCH_CheckDate gets the focus in the main form. I have tried working on this for about an hour and have yet to come up with a solution. What is the best way to accomplish this task?

Thanks,
Chris
dhookom (Programmer)
10 Aug 12 14:58
Set the focus to the Parent of the subform and then set the focus to the control on the parent.

Duane
Hook'D on Access
MS Access MVP

CVesta81 (TechnicalUser)
10 Aug 12 15:29
Is it possible to help me with the code? I'm not familiar with setting focus to a parent. This is the code I tried:

CODE --> VBA

Forms!frmA1SalesOrders.SetFocus
    Forms!frmA1SalesOrders!RCH_CheckDate.SetFocus 

What am I doing wrong?
missinglinq (Programmer)
10 Aug 12 19:46
If RCH_CheckDate is the Control that is to receive Focus:

Me.Parent.RCH_CheckDate.SetFocus

Linq ;0)>

The Missinglinq

Richmond, Virginia

The Devil's in the Details!

Helpful Member!  dhookom (Programmer)
10 Aug 12 21:56
IIRC you need to set the focus first to a form or subform and then another statement to set the focus to a control on that form.

This worked for me from a [Description] control on the subform:

CODE --> vba

Private Sub Description_LostFocus()
    Me.Parent.SetFocus
    Me.Parent.RCH_CheckDate.SetFocus
End Sub 

Duane
Hook'D on Access
MS Access MVP

missinglinq (Programmer)
10 Aug 12 22:13
Your memory is half-right, Duane. When moving from a Main Form to a Control on a Subform you have to first set Focus on the Subform Control, then on the target Control, but the reverse is not true!

CODE

Me.Parent.RCH_CheckDate.SetFocus 

works just fine in 2007, without setting Focus to the Main Form first.

In point of fact, while you can always set Focus to a Subform Control, you can only set Focus to a Form if there are no Controls on the Form that can receive Focus.

Linq ;0)>

The Missinglinq

Richmond, Virginia

The Devil's in the Details!

CVesta81 (TechnicalUser)
13 Aug 12 13:01
OK, so neither of those worked for me for some reason. I am including the code in the LostFocus for the last control in my subform (Private Sub Notes_LostFocus()). I am getting the message, "Run-time error '438': Object doesn't support this property or method." What am I doing wrong? Do I need to include this code on the LostFocus of the subform itself?
dhookom (Programmer)
13 Aug 12 15:31
I would attempt to determine which line of code is causing the error.

Duane
Hook'D on Access
MS Access MVP

CVesta81 (TechnicalUser)
13 Aug 12 16:45
Me.Parent.RCH_CheckDate.SetFocus
Helpful Member!  missinglinq (Programmer)
13 Aug 12 21:21
Basically, Access is saying that RCH_CheckDate is not a Control that Focus can be set to. Is it a Field name, perhaps, rather than the name of the Textbox that is bound to RCH_CheckDate?

In Form Design View, click on the Control to select it and go to Properties - Other and see what's in the Name Property Box.

Linq ;0)>

The Missinglinq

Richmond, Virginia

The Devil's in the Details!

CVesta81 (TechnicalUser)
14 Aug 12 20:57
Perfect! Missinglinq, you were right! I was referencing the field and not the control. The names were very similar, but not identical. I appreciate everyone's help with this!
missinglinq (Programmer)
14 Aug 12 22:23
Glad we could help!

Good luck with your project!

Linq ;0)>

The Missinglinq

Richmond, Virginia

The Devil's in the Details!

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close