Set focus from code - InfoPath Dev
in

InfoPath Dev

Set focus from code

Last post 09-29-2011 12:36 AM by Jimmy. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 03-19-2010 03:46 AM

    Set focus from code

    Hi all,

    This is the first time I'm working with Infopath (2007), and it's not going as expected :-(

    Before saving a form, I have to validate a few fields (in vb). If one of the fields contains invalid data, an error message appears and the focus has to be set to that specific field.
    The last part seems to be a problem.

    I've already searched this forum, and I found several solutions which unfortunately don't work.

    Public Sub btnSave_Clicked(ByVal sender As Object, ByVal e As ClickedEventArgs)
    Dim WTG As String = Me.CreateNavigator().SelectSingleNode("/ns1:Boatlanding/WTG", Me.NamespaceManager).Value
    If WTG = "" or WTG = "64" Then
       MessageBox.Show("WTG is required")
      
    -- Set focus back to WTG ---
      
    Return
    End If
    ...
    End sub

    Can someone please help me ?

    Thanks,

    Ingrid

  • 03-19-2010 05:50 AM In reply to

    You can probably use the SelectText method to select a control, but using code to perform validation this simple seems like overkill.

    http://msdn.microsoft.com/en-us/library/aa944234.aspx
    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 03-19-2010 07:58 AM In reply to

    Hello Jimmy,

    Thank you very much for the tip. It works fine now.

    Regards,

    Ingrid

  • 09-28-2011 11:27 PM In reply to

    Hi Jimmy,

    Its seems given URL is not available, could you please provide the alternate URL or the content of this URL or sample code?.

    Thank you... 

     

     

  • 09-29-2011 12:36 AM In reply to

    Fixed the link.  There was just an extra %20 hiding at the end

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
Page 1 of 1 (5 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.