Not able to pass values from VB.NET to InfoPatch - InfoPath Dev
in

InfoPath Dev

Not able to pass values from VB.NET to InfoPatch

Last post 02-14-2012 05:02 PM by kerberos. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 02-11-2012 09:59 PM

    Not able to pass values from VB.NET to InfoPatch

    Hi all, 

    I have a single field on the form that I want to calculate in VB.NET and pass the value into the form.
    Im using infopath compatilble with 2007 code.
    the field on the form is weekdays and its defined as string.

     My code in VB is the following:

    Private Sub InternalStartup(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Startup

    Dim weekdays As String

    MainDataSource.CreateNavigator().SelectSingleNode("/myFields/my:weekdays")

    weekdays = DatePart("ww", Today)

    End Sub

    Wwhen I run it I get the following error:

    Namespace Manager or XsltContext needed. This query has a prefix, variable, or user-defined function.

     

    Any ideas?

     

    thanks,

  • 02-13-2012 09:37 AM In reply to

    Re: Not able to pass values from VB.NET to InfoPatch

    You need to include a NamespaceManager:

    MainDataSource.CreateNavigator().SelectSingleNode("/myFields/my:weekdays", NamespaceManager)

     

    Hilary Stoupa

  • 02-14-2012 05:02 PM In reply to

    Re: Not able to pass values from VB.NET to InfoPatch

    Thanks Hilary,

    That was it, it worked perfectly.

    I was able to pass the value to the form.
    Now, how can I get the value from the form? :)

    Im doing this

    Private Sub InternalStartup(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Startup
    Dim weekoftheyear As String
    weekoftheyear = DatePart("ww", Today)
    MainDataSource.CreateNavigator().SelectSingleNode(
    "/my:myFields/my:Time_sheet/my:weekoftheyear", NamespaceManager).SetValue(weekoftheyear)

    'read from form date picker
    Dim dateselected As XPathNavigator = Me.CreateNavigator.SelectSingleNode("/my:myFields/my:Time_sheet/my:week_of", NamespaceManager)
    'write to form another date picker or text field
    MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:Time_sheet/my:newdatecheck", NamespaceManager).SetValue(dateselected)

     

    I want to replace the Today with my dateselected fiedl from the form and do the calculations based on the inserted date.

     

    again thank you,

     

    Kerb,

Page 1 of 1 (3 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.