I am new to InfoPath. I am using 2003 version.
I need to create button on my form with code in VBScript for: reading data from some data connection (some library on Sharepoint) and take Maximum value from some field.
I don't know how to do in VBScript link on this field.
I am able create Combobox (or Listbox) in Form, where I see this data from this connection (data connection has name: CislaZN, value for Combobox is (taken from external source data): /dfs:myFields/dfs:dataFields/dfs:ZlepsovaciNavrhy/@Cislo_ZN
I tried to do it by dataField, but then I am not able go on next record or I don't know how to do it (I tried do it the same as in repeating field by [], but here I take error that record [2] doesnt exist). Code on button is:
Sub CTRL56_5_OnClick(eventObj)
Dim Pom, I, Number, Max
I=1
' We take first record - it is ok
Pom="/my:ZlepsovakyForm/my:Hlavicka/my:CislaZN["+cstr(I)+"]"
Number=XDocument.DOM.selectSingleNode(Pom).text
Max=Number
do while Number<>""
' We take second record - problem = doesn't exist (how to take second record?)
I=+1
Pom="/my:ZlepsovakyForm/my:Hlavicka/my:CislaZN["+cstr(I)+"]"
Number=XDocument.DOM.selectSingleNode(Pom).text '
if Number>Max then Max=Number
loop
XDocument.DOM.selectSingleNode("/my:ZlepsovakyForm/my:Hlavicka/my:CisloZN").text=Max
End Sub