set control value via vba works only once

O

Oliver Friedrich

Hallo,

I have a form where I want to insert a path into a string control
"resourceDescriptor". When I click the button "CTRL13_7" I want to open a
fileDialog where I can select the file and then write that value to the
control.

When I open the form this works only once. After "insert new record" it
doesn't copy anymore. There are no errors or warnings popping up, neither
in InfoPath nor in VisualStudio. Can anybody help me resolve this
problem?

Here's my code:

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

Dim nav As System.Xml.XPath.XPathNavigator
nav = Me.MainDataSource.CreateNavigator


Dim path As String
Dim fileDialog As OpenFileDialog

fileDialog = New OpenFileDialog
fileDialog.Filter = "txt files (*.txt)|*.txt|All files (*.*)
|*.*"

If (fileDialog.ShowDialog = DialogResult.OK) Then
path = fileDialog.FileName
nav.SelectSingleNode
("/dfs:myFields/dfs:dataFields/d:Test/@resourceDescriptor",
Me.NamespaceManager).SetValue(path)
End If


End Sub


Greetings

Oli
 
S

Shiva (GGK Tech)

Hello,

Can you debug once your application? Whenever you are clicking on “CTRL13_7â€
button event it is trying to execute it or not? If your code is trying to
execute then give more details on error.
 
O

Oliver Friedrich

Hello,

Can you debug once your application? Whenever you are clicking on
“CTRL13_7†button event it is trying to execute it or not? If your
code is trying to execute then give more details on error.

Hallo,

thanks for your reply.
The code for the button event is executing every time I click the button.
The openFileDialog also works correct and returns the correct string in
"path". The problem is setting the value of the node. This works as long as
I don't send the form to the database or I insert a new record. After that
the setting of the node has no effect on the form's control anymore.

maybe, that helps you clarify the problem.

Oli
 
A

Anuma(GGK Tech)

Hi,

I think your problem is with xpath. You given "d:Test" instead of "dfs:Test".
 
A

Anuma(GGK Tech)

And also you did not enter namspace before the the atribute field.
"@resourceDescriptor" should be changed to "@dfs:resourceDescriptor"

Your xpath should be like this:
"/dfs:myFields/dfs:dataFields/dfs:Test/@dfs:resourceDescriptor"
 
Top