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