VBscript code to point to a field - InfoPath Dev
in

InfoPath Dev

VBscript code to point to a field

Last post 02-10-2010 09:05 AM by Greg Collins. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 02-03-2010 01:28 PM

    VBscript code to point to a field

    I need to know how to point to a field using vbscript. The fields are from a SQL server if that makes any differents. The SQL server database is connected to the form and I want to do some math to add up fields and divide and spit out the results in a textbox. Thanks...

    Filed under: ,
  • 02-09-2010 09:04 AM In reply to

    Re: VBscript code to point to a field

    If the calculation is not complicated you should consider using Rules to accomplish this task.

    Otherwise, there should be plenty of InfoPath VBScript examples online, but the basics of the selection are:

    nodeVariable = thisXDocument.DOM.selectSingleNode(___XPATH_HERE___)

    The XPATH must be fully qualified, meaning it has to have all the right namespace prefixes, something like:

    /dfs:myFields/dfs:dataFields/d:table/@column

  • 02-09-2010 11:07 AM In reply to

    Re: VBscript code to point to a field

    Thanks Greg... I can write code in VB and VBA. When writing code in those app. once you type in a valid name and press period there will be a drop down box. I dont see a box coming up nor does the appliacation auto fix var names to keep the names the same all through code. Is this normal or is there some going on with my script?

     Also I am getting this error when testing the code.

    Object required: 'thisXDocument'

    nodeVariable = thisXDocument.DOM.selectSingleNode("/dfs:myFields/my:test")

    msgbox nodeVariable

     

    Please help!!

  • 02-10-2010 09:05 AM In reply to

    Re: VBscript code to point to a field

    Sorry, my mistake... I haven't done script in InfoPath for a long time. The initial object is "XDocument" (used in Script) not "thisXDocument" (which is used in VB.NET and C#)

Page 1 of 1 (4 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.