Newbie:Accessing form controll from vbscript

P

Peter

Hi,

I have look high and low on this one, but no luck so far :-(

I have a form with a repeating table connected to a SQL Server
database. On this repeating table, I have a textbox called 'Name'.
From VBScript, I want to retrieve the value (or text) typed into this
textbox and put it in a variable called vName. How is this done?

I've tried many combinations now, but nothing has worked.

TIA
 
B

Ben Walters

Hey Peter,
InfoPath is a data driven development environment not an object oriented
development. So rather than looking for a control to get your information
out of e.g. TextBox1.Text you would retrieve the xml node that holds the
data e.g.
if you had a form with the following structure

<root>
<name></name>
</root>

You would attempt to return the name node and get it's contents.
how you do this differes slightly from IP2003 to IP2007

In InfoPath 2003 you use the MSXML based object model to access you data so
retrieving your name node would look something like this

this.XDocument.DOM.SelectSingleNode("/name").text

In InfoPath 2007 the object model has been moved to a .net based xml
structure so retrieving your name node would look like this

XPathNavigator myNavigator = this.CreateNavigator();

myNavigator.SelectSingleNode("/name",NamespaceManager).Value



Hope this helps
Cheers
Ben
 
M

MOT

Hi. Thanks for your help :)

If I do this:

Dim vName
vName = this.XDocument.DOM.SelectSingleNode("NAME").text

I get this: Object required 'this'

If I remove 'this' I get: Object required
'XDocument.DOM.SelectSingleNode(...)'

I also tried adding the 'set' keyword in front, but it gave me the same
error. If I double click the textbox, the Field name says "NAME", so I
should be using the correct name for the textbox. Any suggestions?

I'm using InfoPath 2003 SP2

TIA
/Peter


Ben Walters skrev:
 
P

Peter

Hi. Thanks for your help :)

If I do this:

Dim vName
vName = this.XDocument.DOM.SelectSingleNode("/NAME").text

I get this: Object required 'this'

If I remove 'this' I get: Object required
'XDocument.DOM.SelectSingleNode(...)'

I also tried adding the 'set' keyword in front, but it gave me the same
error. And I tried with "NAME" (without the slash in front). Same
error. If I double click the textbox, the Field name says "NAME", so I
should be using the correct name for the textbox.

In "Data source" I have:

myFields
dataFields
d:Cust
:NAME

Any suggestions?

I'm using InfoPath 2003 SP2

TIA
/Peter


Ben Walters skrev:
 
B

Ben Walters

Sorry Peter the code I provided was for C# not VB,

for vb you want to replace this with Me

Cheers
 
B

Ben Walters

Hey Peter,
My last post may not have come through so sorry if this is repeated
the code I provided was for C# not Visual Basic, so you'll have to replace
"this" with "Me"

let me know how you go

Cheers
Ben
 
P

Peter

Hello Ben, Thanks again for your reply :)

With Me instead of this, I get:

Object doesn't support this property or method: 'Me.XDocument'

Any suggestions?

TIA
/Peter


Ben Walters skrev:
 
B

Ben Walters

Hey Peter
I don't have InfoPath 2003 installed on my machine at the moment, but I do
have an environment at home to check out.

In the interim you could try accessing the XDocument object via e.Xdocument
the e variable is passed on the event of your control


Hope this helps

Cheers
Ben
 
R

radhika.kashetti

Ben said:
Hey Peter
I don't have InfoPath 2003 installed on my machine at the moment, but I do
have an environment at home to check out.

In the interim you could try accessing the XDocument object via e.Xdocument
the e variable is passed on the event of your control


Hope this helps

Cheers
Ben
 
R

radhika.kashetti

Hi Peter,

No need to mention me or this in front of XDocument.... u just remove
those and try....
if u want to retrieve the data from a text box of repeating table u
just do as follow
in vbscript
dim vName
vName = XDocument.DOM.selectSingleNode("the XPath of that
textbox").text
by this u will get the data of textbox into vName...
Try this....
 
R

radhika.kashetti

Ben said:
Hey Peter
I don't have InfoPath 2003 installed on my machine at the moment, but I do
have an environment at home to check out.

In the interim you could try accessing the XDocument object via e.Xdocument
the e variable is passed on the event of your control


Hope this helps

Cheers
Ben
 

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