424,294 Members | 1,891 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,294 IT Pros & Developers. It's quick & easy.

SetFocus to a Form control when cursor is in Split Form datasheet

P: 62
Hello -

I have a Main form with a Split Form view.

I have an OnCurrent event that runs when the user selects a different record in the Split Form.

The first part of the OnCurrent event is as follows:

Expand|Select|Wrap|Line Numbers
  1. [Forms]![f_MainTripForm_Admin].SetFocus
  2. [Forms]![f_MainTripForm_Admin]![TripStartDate].SetFocus
However, the focus is staying on the TripStartDate field in the SplitForm, and not moving to the TripStartDate field in the Main form as desired.

I need to move the focus to the TripStartDate control on the form so that I can run the remainder of the OnCurrent event which shows or hides various controls on the Main form depending on the type of record the user is viewing. Otherwise, the focus could be on a control that I am trying to hide and I will get the "Can't hide a control that had the focus" error.

Thanks for your help,
Sandra
Sep 26 '12 #1

✓ answered by Seth Schrock

Is there something special about TripStartDate other than it is always visible? If not, you should be able to setfocus on either a button the the form or even possibly the form title in the header if you have one. Anything that isn't in both the main portion and the datasheet portion of the form should take out the ambiguity of which control you are referring to.

Share this Question
Share on Google+
6 Replies


zmbd
Expert Mod 5K+
P: 5,285
You are using the built in split form type as available in v2007/2010 or is this something you've designed?
Sep 26 '12 #2

Seth Schrock
Expert 2.5K+
P: 2,920
Is there a button that you could set focus on it? You might also try setting focus on the Form's detail section. The problem with the split form is that the name of the control in the main part of the form is the same as the control in the datasheet portion of the form. I don't believe that there is a code to differentiate between the two. It just picks the one that is in the same section as you just clicked, which sounds like you are in the datasheet portion.
Sep 26 '12 #3

P: 62
Thanks guys.

Z: I am using the default splitform option in Access 2010

Seth: Yes, I am clicking a record in the datasheet/splitform view and triggering the OnCurrent event that changes what controls are visible on the Main form view.
Sep 26 '12 #4

Seth Schrock
Expert 2.5K+
P: 2,920
Is there something special about TripStartDate other than it is always visible? If not, you should be able to setfocus on either a button the the form or even possibly the form title in the header if you have one. Anything that isn't in both the main portion and the datasheet portion of the form should take out the ambiguity of which control you are referring to.
Sep 26 '12 #5

P: 62
Thanks Seth - great idea.

This worked perfectly!

Expand|Select|Wrap|Line Numbers
  1. [Forms]![f_MainTripForm_Admin].SetFocus
  2. [Forms]![f_MainTripForm_Admin]![ButtonName].SetFocus
many thanks,
Sandra
Sep 26 '12 #6

Seth Schrock
Expert 2.5K+
P: 2,920
Not a problem. Glad I could assist you.
Sep 26 '12 #7

Post your reply

Sign in to post your reply or Sign up for a free account.