navigation forms set focus

Snowflake68

Registered User.
Local time
Today, 12:39
Joined
May 28, 2014
Messages
464
I have a main navigation form called frmMain which has with 6 navigation buttons each with their own form with the NavSubForm. One of the buttons is named navSection1 and a subform named DS within the NavSubForm. On the DS subform I have a combo box called cboBillTo which I am trying to set focus on when I click on the navbutton but I cannot get the syntax correct in order to do so.

I have tried
Code:
Forms![DS]!cboBillTo.SetFocus

and
Code:
Me.DS.setfocus
immediately followed by
Code:
DS.cboBillTo.setfocus

but above lines either say cannot find the referenced form or 'Method or data member not found'

I have this piece of code on the onClick event of the nav button to determine which control has the focus immediately after I click it and it says that navSection1 has the control. So I thought it should be simple enough to reference a control on the DS form that is held within that.:banghead:

Code:
    MsgBox Screen.ActiveControl.Name, 0, "Active Control"
 
use the BUILDER, it always gets the path correct.
normally, if you want to access the subform,theres another layer, its like:

forms!masterForm!subFrm!form!cbobox.setfocus
 
I should also add that I have tested using the BrowseTo action in a macro and run that from a button from a different section of the main form and it all works ok with the cboBillTo control immediately getting the focus.

Attached is the BrowseTo macro action which I dont know how to convert.

I i put this macro on the OnClick event of the navigation button (just to test it) the cboBillTo doesnt get the focus, so I guess it has something to do with which form is loaded first possibly but I am still baffled so hopefully someone can help me.

Thanks
 

Attachments

  • BrowseToControl.JPG
    BrowseToControl.JPG
    20 KB · Views: 196
use the BUILDER, it always gets the path correct.
normally, if you want to access the subform,theres another layer, its like:

forms!masterForm!subFrm!form!cbobox.setfocus

i cant get the builder to come up when in the visual basic window, how do I do this please?
 
I have this piece of code on the onClick event of the nav button to determine which control has the focus immediately after I click it and it says that navSection1 has the control. So I thought it should be simple enough to reference a control on the DS form that is held within that.:banghead:

Code:
    MsgBox Screen.ActiveControl.Name, 0, "Active Control"

The "OnClick" event for navSection1 would execute if navSection1 has focus and is clicked.

From your description, you can either set focus to your desired control from, IIRC, On Current in the sub form OR by setting the tab order for the subform so your desired control is first in tab order.

Just one bit to be clear about, are you referring to subforms already on a form or are you opening new forms?
each with their own form with the NavSubForm.
is a little confusing to me. I would expect SubForm to be a sub form control on an existing form so you would not normally need to use a button to navigate to one.
 
Code:
MsgBox Screen.ActiveControl.Name, 0, "Active Control"
The "OnClick" event for navSection1 would execute if navSection1 has focus and is clicked.
I only added this to test to see if the focus had moved after I click the nav button.

From your description, you can either set focus to your desired control from, IIRC, On Current in the sub form OR by setting the tab order for the subform so your desired control is first in tab order.
I dont know what IIRC is. I do have the cboBillTo as the first tab control set to 0 but it does not get the focus until I actually click anywhere on the form.

Just one bit to be clear about, are you referring to subforms already on a form or are you opening new forms? is a little confusing to me.
I am not opening up any other forms its just the one main form that contains all of the navigation subform.

I would expect SubForm to be a sub form control on an existing form so you would not normally need to use a button to navigate to one.

I only did this as a proof of concept. I understand that clicking on the button would in fact navigate to the correct section of the navigation form. i just wanted to test to see if it was the clicking of the navigation button that was causing the issue. Which it does appear to be.
 
Last edited:
I am still trying (in vain :banghead:) to get the set focus to work. The control i need to set the focus on is in the header of the subform of the NavigationSubform.

I have set the tab stop to 0 but it doesnt get the focus until you click on the form.

It seems that when you click the navigation button that the focus stays with the nav button and does not move to the form that is contained within it.

Is this an issue with the way the navigation forms work?

I have uploaded a sample database showing the issue I have. When you open up the application, just click on the tab that says 'New Quote'. You will see a message that says which control has the focus. I added this just for testing to confirm the active control. The combo box Bill To doesn't have the focus until you click on the form. Which is the issue I have.

Hope someone can help me with this as its driving me insane.
 

Attachments

Set the focus to the "NavigationSubform".

You are a genius, this is so simple thank you so much. Works perfectly. I cannot thank you enough from a rescued damsel in distress. :D
 
You're welcome, good luck! :)
 

Users who are viewing this thread

Back
Top Bottom