locked
pass dynamic parameter between forms RRS feed

  • Question

  • Now I want to implement that when I click any row of a repeating table, it will come up a new form which filled with more details depends on current row's ID. Now i am still testing, two forms and the database are on my computer (not on the server)

    I know there are two ways to implement that. One is command line, but in my case I need to pass dynamic parameter so I think this dosen't work.

    the other one is using the URL

    I tried C:\Documents and Settings\speng\Desktop\Infopaht template\Record.xsn?UserID=1 to open a new form, it doesn't work either. so I used the following code

        Public Sub Select_Clicked(ByVal sender As Object, ByVal e As ClickedEventArgs)
          Dim recordForm As XmlForm = Me.Application.XmlForms.NewFromFormTemplate("C:\Documents and Settings\speng\Desktop\Infopaht template\Record.xsn")
          Dim UserID As XPathNavigator = recordForm.MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:UserID", NamespaceManager)
          UserID.SetValue("1")
        End Sub
    

    the second line code can open a new form, but when I add the third and fourth lines,  there will be an error said "Object reference not set to an instance of an object." I also created a textbox called UserID to recieve the parameter.

    Does anyone has any suggestion? Many thanks

    Wednesday, August 3, 2011 7:22 PM

Answers

  • I finially made this out by add a secondary datasource, it works fine. Maybe the problem is on the MainDataSource. Here is the code I used

    Dim recordForm As XmlForm = Application.XmlForms.NewFromFormTemplate("C:\Documents and Settings\speng\Desktop\Infopaht template\Record.xsn")
          Dim recordDatasource As DataSource = recordForm.DataSources("tbl_TemporaryLicence")
          recordDatasource.CreateNavigator().SelectSingleNode("/dfs:myFields/dfs:dataFields/d:tbl_TemporaryLicence/@TempPermitID", NamespaceManager).SetValue(a)
    
    

     

    • Proposed as answer by Melissa Renton MCTS Thursday, August 4, 2011 8:07 PM
    • Marked as answer by Emir Liu Friday, August 12, 2011 10:19 AM
    Thursday, August 4, 2011 7:20 PM

All replies

  • Is this a browser-enabled form?  If not (meaning it's a filler form) you can use the built in Master-Detail relationship to show the related data underneath the repeating table based on the selected row.  This creates a better user experience vs. a new form opening each time they click on a row. 

    Wednesday, August 3, 2011 7:34 PM
  • Thanks for your reply, but this structure has been desiced at the very beginning. we don't wanna make the main form too complicated (with too much detail infomation) and finially we will put these form on our sharepoint server (does that mean a browser enabled form?), so I think I still need a way to pop up the new form in my case
    Thursday, August 4, 2011 1:01 PM
  • I finially made this out by add a secondary datasource, it works fine. Maybe the problem is on the MainDataSource. Here is the code I used

    Dim recordForm As XmlForm = Application.XmlForms.NewFromFormTemplate("C:\Documents and Settings\speng\Desktop\Infopaht template\Record.xsn")
          Dim recordDatasource As DataSource = recordForm.DataSources("tbl_TemporaryLicence")
          recordDatasource.CreateNavigator().SelectSingleNode("/dfs:myFields/dfs:dataFields/d:tbl_TemporaryLicence/@TempPermitID", NamespaceManager).SetValue(a)
    
    

     

    • Proposed as answer by Melissa Renton MCTS Thursday, August 4, 2011 8:07 PM
    • Marked as answer by Emir Liu Friday, August 12, 2011 10:19 AM
    Thursday, August 4, 2011 7:20 PM