infopath query result always same - InfoPath Dev
in

InfoPath Dev

infopath query result always same

Last post 08-08-2011 12:02 PM by yuwenlanxing. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 08-08-2011 09:46 AM

    infopath query result always same

    Now I have two infopath forms 1 and 2. there is a repeating table in form 1 with a button in each row, when click this button, the form 2 will pop up with more detail information and the value of current row's ID will be sent to the form 2.

    my problem is nomatter which row i select, the ID field in form 2 is correct, but other fields always filled with the values of the first row.

    code of form 1:

    Public Sub Select_Clicked(ByVal sender As Object, ByVal e As ClickedEventArgs)

         Dim ID As String = e.Source.SelectSingleNode("@TempPermitID").Value

         Dim recordForm As XmlForm = Application.XmlForms.NewFromFormTemplate("C:\Documents and Settings\speng\Desktop\Infopaht template\comeoutrecord.xsn")

         Dim recordDatasource As DataSource = recordForm.DataSources("tbl_TemporaryLicence")

         recordDatasource.CreateNavigator().SelectSingleNode("/dfs:myFields/dfs:dataFields/d:tbl_TemporaryLicence/@TempPermitID", NamespaceManager).SetValue(ID)

    End Sub

     

    code of form 2:

    Public Sub FormEvents_Loading(ByVal sender As Object, ByVal e As LoadingEventArgs)

    Dim RegNo As String = ""

    Dim _RegNo As XPathNavigator = Me.DataSources("tbl_TemporaryLicence").CreateNavigator().SelectSingleNode("/dfs:myFields/dfs:dataFields/d:tbl_TemporaryLicence/@TempPermitID", NamespaceManager)

    RegNo = _RegNo.Value

    Try

    Dim myAdoQueryConnection As AdoQueryConnection = DirectCast(Me.DataConnections("tbl_TemporaryLicence"), AdoQueryConnection)Dim sqlString As String = "SELECT * FROM tbl_TemporaryLicence WHERE TempPermitID = " & RegNo

    myAdoQueryConnection.Command = sqlString

    myAdoQueryConnection.Execute()

    Catch ex As Exception

    MessageBox.Show(ex.Message)

    End Try

    End Sub

    is there any suggestion? Many thanks

  • 08-08-2011 10:41 AM In reply to

    Re: infopath query result always same

    Hi - when are you setting other values in form 2? Are you getting the correct "RegNo" from your main data source - that is, are you passing the correct value to your query? Have you looked at what your query returns in form 2? That is, drag that secondary data connection onto the form so you can see the results - is your query returning what you anticipate?

    Hilary Stoupa

  • 08-08-2011 12:02 PM In reply to

    Re: infopath query result always same

     1. when are you setting other values in form 2?

      every time when opening the form 2, it will run this sql to get all fields value.

      Dim sqlString As String = "SELECT * FROM tbl_TemporaryLicence WHERE TempPermitID = " & RegNo

    2. Are you getting the correct "RegNo" from your main data source

    that the problem. For example, i click row 3 in form 1, only the ID field will filled with 3, I think that means it passes 3 to form 2. But in that SQL , the value of RegNo is always the value of the first row in form 1.

    if ID field in form 2 can get 3, why when I use Dim _RegNo As XPathNavigator = Me.DataSources("tbl_TemporaryLicence").CreateNavigator().SelectSingleNode("/dfs:myFields/dfs:dataFields/d:tbl_TemporaryLicence/@TempPermitID", NamespaceManager)

    RegNo = _RegNo.Value

    the value of RegNo is not 3.

    and thanks for your reply

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