focus - InfoPath Dev
in

InfoPath Dev

focus

Last post 11-15-2009 04:14 AM by Patrick Halstead. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 11-11-2009 06:45 AM

    focus

    We use Infopath 2003.

    In the OnValidate event for a Date Picker field (ExpDate) I first check to see if it is a valid date.  If not, I display a message box and I would also like focus to remain or return to the ExpDate field.  I am having trouble with this last part.  Here is my bit of code:

    <InfoPathEventHandler(MatchPath:="/ns1:ProcessDocument/ns1:Document/ns1:PersonalReimbursement/ns1:ExpenseItems/ns1:item/ns1:ExpDate", EventType:=InfoPathEventType.OnValidate)> _
    Public Sub ExpDate_OnValidate(ByVal e As DataDOMEvent)
    Dim xpnRoot As IXMLDOMNode
    xpnRoot = thisXDocument.DOM.selectSingleNode(
    "/")
    Dim ExpDate As IXMLDOMNode = xpnRoot.selectSingleNode("/ns1:ProcessDocument/ns1:Document/ns1:PersonalReimbursement/ns1:ExpenseItems/ns1:item/ns1:ExpDate")
    If IsDate(ExpDate.text) = False Then
    MessageBox.Show("Please enter an Expense Date")
    [here is where I would like to set the focus]
    End If
    End Sub

    I have looked at focus, set focus in visual basic help and on-line but am not sure how to do this.  Any help would be very appreciated.  Thanks.

    Mary

    Mary
  • 11-15-2009 04:14 AM In reply to

    Hi Mary,

    There's an object model method called SelectText or SelectNodes (for a group) that will put the cursor in the field (or group) that you want. Take a look at the InfoPath 2003 SDK (InfoPath.dev->resources on right side of home page). 

    Patrick Halstead
    Project Manager at Qdabra
Page 1 of 1 (2 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.