dgoldie
asked on
Retrieve infopath field value
Hi,
I'm trying to get the value of a form field to use in an If Statement on an infopath 2007 form. I'm used to VBA where I could use "If me.fieldname.value = X then..." however I'm struggling to find the equivalent in VB.
Thanks,
Duncan
I'm trying to get the value of a form field to use in an If Statement on an infopath 2007 form. I'm used to VBA where I could use "If me.fieldname.value = X then..." however I'm struggling to find the equivalent in VB.
Thanks,
Duncan
Public Sub CTRL225_5_Clicked(ByVal sender As Object, ByVal e As ClickedEventArgs)
If "code to go here" Then
Application.XmlForms.Open("http://sharepoint.xxxxxxx.net/Sites1/SPptmvpt/TRS3/Country%20Risk%20Assessment/Pakistan.xml", XmlFormOpenMode.ReadOnly)
Else
Application.XmlForms.Open("http://sharepoint.xxxxxxx.net/Sites1/SPptmvpt/TRS3/Country%20Risk%20Assessment/Angola.xml", XmlFormOpenMode.ReadOnly)
End If
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks, it's nearly end of day here so I'll look again tomorrow and let you know how I fare.
ASKER
I managed to find the solution; below is the code which does the job (although not the final version).
The reason I can’t use a hyperlink is because the form I need to open is based on a different dataset and needs to be filtered - the button allows me to set the filter at the same time I open the form whereas with a hyperlink I would need to set the filter value then click on the link. This delay could cause users to be misdirected if they accessed the form simultaneously.
The reason I can’t use a hyperlink is because the form I need to open is based on a different dataset and needs to be filtered - the button allows me to set the filter at the same time I open the form whereas with a hyperlink I would need to set the filter value then click on the link. This delay could cause users to be misdirected if they accessed the form simultaneously.
Public Sub CTRL225_5_Clicked(ByVal sender As Object, ByVal e As ClickedEventArgs)
Dim nav As XPathNavigator = MainDataSource.CreateNavigator()
Dim fieldValue As String = nav.SelectSingleNode("//my:Country", NamespaceManager).Value
If fieldValue = "Pakistan" Then
Application.XmlForms.Open("http://sharepoint.xxxxx.net/Sites1/SPptmvpt/TRS3/Tactical%20Action%20Plans/Economic_Crisis%20Management.xml", XmlFormOpenMode.ReadOnly)
Else
Application.XmlForms.Open("http://sharepoint.xxxxxx.net/Sites1/SPptmvpt/TRS3/Tactical%20Action%20Plans/Natural%20Disaster_Crisis%20Management.xml", XmlFormOpenMode.ReadOnly)
End If
End Sub
ASKER
I've rated your answer as B because although you pointed me in the right direction my I found the actuall code from another site - thanks all the same
ASKER
The reason I nead to use code is because from rules I can only open a new form as opposed to an existing form and I need to use an if statement to choose which form to open so as far as I can see there is no alternative.