setting focus on another control with a command button. - InfoPath Dev
in

InfoPath Dev

setting focus on another control with a command button.

Last post 11-14-2008 03:51 AM by swathip. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 11-13-2008 03:42 AM

    setting focus on another control with a command button.

    Hi folks,

    I'm not really sure how to do this. Just as the heading suggests, is there a way to have a command button on the form and when it's clicked it sets focus on another field on the form?

    Hope someone can help and thanks.

    ____________________________________

    Take a deep breath phsssssssssss
  • 11-13-2008 04:21 AM In reply to

    Re: setting focus on another control with a command button.

    Hi,

    Add the following code lines in the button click event.

     

    IXMLDOMNode focusNode = thisXDocument.DOM.selectSingleNode("xpath of the field in which the focus comes");

     

    If(focusNode!= null)

     

    {

     

    thisXDocument.View.SelectText(focusNode ,Type.Missing);

     

    }

     This is for a normal button placed from controls. What do you mean by command button? 

     

    Swathip
    www.ggktech.com
  • 11-13-2008 05:33 AM In reply to

    Re: setting focus on another control with a command button.

    Hi Swathip, thanks for getting back to me.

     You wrote:
    ("xpath of the field in which the focus comes")

    Im not really sure what to do here? I've only started using InfoPath forms.

    The reason I called the button a command button is just because I usually use Access and that's what I call them, just force of habit I guess.

    Hope you can help me a little more with this

    Thanks

     

    ____________________________________

    Take a deep breath phsssssssssss
  • 11-13-2008 11:12 PM In reply to

    Re: setting focus on another control with a command button.

    Hi,

     

    You will get the xpath of a node by following the below steps.

     

    1.       Open the infopath form in design mode.

     2.       Go to View -> Task Pane. Then you will see a window right side of the form.

     

    3.       In that click on Data source.

     

    4.       Place the cursor on the field which you want to get the focus.

     

    5.       In the right side task pane one value will be selected.

     

    6.       Right click on that field. Then click on Copy Xpath option.

     

    7.       Open a note pad and paste. You will get a value like ‘my:myField/my:field1..”. This value is called Xpath.

     

    Swathip
    www.ggktech.com
  • 11-14-2008 03:09 AM In reply to

    Re: setting focus on another control with a command button.

     

     Hi Swathip,

     This is what I put in. Does this look correct? I get an error in the line:
    IXMLDOMNode focusNode = thisXDocument.DOM.selectSingleNode("myFields/dfs:dataFields/d:MilestoneDetails");

    The error is, Expected ';'

    I don't really know what to do now. I've tried to look for similar syntax in other code examples but can't find anything to help.
    Thanks

    *************************

     function CTRL492_7::OnClick(eventObj)
    {
    IXMLDOMNode focusNode = thisXDocument.DOM.selectSingleNode("myFields/dfs:dataFields/d:MilestoneDetails");
     
    If(focusNode!= null)
     
    {
     
    thisXDocument.View.SelectText(focusNode ,Type.Missing);
     
    }
    ***************************

    ____________________________________

    Take a deep breath phsssssssssss
  • 11-14-2008 03:51 AM In reply to

    Re: setting focus on another control with a command button.

    Hi,

     Once verify the xpath. I think it should be like ‘dfs:myFields/dfs:dataFields/d:MilestoneDetails’ instead of ‘myFields/dfs:dataFields/d:MilestoneDetails’ 

     

    Swathip
    www.ggktech.com
Page 1 of 1 (6 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.