Return single node value

H

Humphrey

I know this is going to be a great DOH!! moment but how do I return the value
in a field from my document in 2007? My code is as follows,

Dim StandardJobName As XPathNavigator =
Me.MainDataSource.CreateNavigator()
Msg =
StandardJobName.SelectSingleNode("/my:myFields/my:StandardJobName",
Me.NamespaceManager).Value
MessageBox.Show(Msg, "Standard Job Title")

but it keeps giving errors and does not return the value in the field. Can
someone point me in the right direction?

H
 
H

Humphrey

No idea since the err.number, err.description I'm use to in VBA doesn't seem
to work. All I know is that the code goes via the ErrorHandler: displays a
message that it is in there and then the Resume Next continues the code.
Could we start with how to display error details in VB?

H
 
S

S.Y.M. Wong-A-Ton

Sure, but please keep in mind that that's not InfoPath-related and the best
place to ask such questions is in one of the .NET newsgroups. We try to limit
the questions posted here to InfoPath.

Put your code between a try-catch block as follows:

Try
' Code goes here
Catch ex As Exception
Dim message As String = ex.Message
End Try

If you debug your code, you will see the error message in the "message"
variable. Alternatively, remove all error handlers that you currently have
and InfoPath should show you a message box with an error if an error takes
place.
 
H

Humphrey

Thanks I'll test that out. But do you see any problem with my original
InfoPath code?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top