How do I access a textbox value using VBScript - InfoPath Dev
in

InfoPath Dev

How do I access a textbox value using VBScript

Last post 08-03-2009 08:39 AM by HikerSkier. 6 replies.
Page 1 of 1 (7 items)
Sort Posts: Previous Next
  • 07-23-2009 06:03 AM

    How do I access a textbox value using VBScript

    This seems like a really basic thing to do but I can't seem to solve it.

    I created an InfoPath form and added some textboxes in a section. I need to make some changes using VBScript but can't figure out how to retrive or update the data in the text box. When I go into Textbox Proerties | value fx | Insert Fields my data structure looks like this: myFields.group1.MType for the 1st field. There are more fields under myFields.group1 and several other groups.

    I've tried everything I can think of to just display the data in a button click event. I entered data in MType as a test to prove I can get at the data in the text box. I've tried the following plus lots of other things and nothing works.

    Dim answer

    answer = myFields.group1.MType

    MsgBox(answer) 

    I know there must be a very simple solution. can someone help me.

    Thanks

    HikerSkier
  • 07-23-2009 09:06 AM In reply to

    Re: How do I access a textbox value using VBScript

    Hi--

    You need to use something like:

    Dim answer
    Set answer = XDocument.DOM.selectSingleNode("my:myFields/my:group1/my:MType").text

    myFields.group1.MType is not XPath, which is what we use to access the data in a node. If the Xpath in quotes above is incorrect (which, since I am guessing the namespaces, it very well could be!) you'll get an object required error when you try to access the text in the node.

    Hilary Stoupa

  • 07-23-2009 10:45 AM In reply to

    Re: How do I access a textbox value using VBScript

    Thanks Hillary; you got me by the 1st problem.

    I have never worked with XPath before so this is all new to me.

    Now the hard part. I have to figure out how to update the InfoPath manifest file to change URL's so we can promote the InfoPath forms from Dev, to QA and then to Production in SharePoint. I have a few samples from a co-worker that hopefully will help. 

     

    HikerSkier
  • 07-23-2009 01:00 PM In reply to

    Re: How do I access a textbox value using VBScript

    Do you mean for data connections in your form? You can modify that in manifest.xsf. Always save a copy of your form before saving as source files, in case you make a mistake! I actually (not that I'm recommending this) use find and replace to update things like this.... Open manifest.xsf in a text editor, find 'http://myDevSharePoint/DevSite' and replace with 'http://myTestSharePoint/TestSite'.

    Hilary Stoupa

  • 07-24-2009 05:32 AM In reply to

    Re: How do I access a textbox value using VBScript

    Hi Hilary,

     

    Thank you again for your advice. We are aware that we can manually change the data connections in the manifest file. Since I’m between projects I got assigned to see if we can find a way to update all the data connections using some code. We think that the new URL’s will have to be provided by the person who created the InfoPath forms.

     

    As far as we know there is nothing available from Microsoft or any 3rd party and we have not found anything posted that will do this. So this seems to be a challenge. We considered writing a C# program and also imbedding VBScript code into the InfoPath forms.

     

    I have some SharePoint and InfoPath training and  .NET skills but this is new to me. Since you recommended using a text editor to modify the manifest I assume your organization has not found a better solution. I am using Notepad2. It’s terrific.

     

    I’m going to Baltimore SharePoint Saturday tomorrow. I’ve been advised by our management that they don’t think anyone there will be able to help but I like going to these types of events anyway.

     

    Thanks again

     

    HikerSkier
  • 07-24-2009 07:25 AM In reply to

    Re: How do I access a textbox value using VBScript

    We use CabLib in our solutions when we need to programmatically fix up an InfoPath template.  It's a free library for extracting and compressing .CAB files (.XSNs are essentially just .CABs).

    Depending on how many of these templates you have to deal with, you may want to give CabLib a try.  Or you could take a midway approach, whereby you extract the templates manually but create a tool to fix up the manifest.xsf files (they can be processed as XML so they would be well suited for this).

     Best of luck in any case.

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 08-03-2009 08:39 AM In reply to

    Re: How do I access a textbox value using VBScript

    I'm making progress. I used VBScript to redirect the InfoPath form to a different SharePoint Document Library. See below.

    strURL = XDocument.DOM.SelectSingleNode(//my:myFields/my:group1/my:strURL").text 

    set myAdapter = XDocument.DataAdpaters("Adapter Name")

    myAdapter. FolderURL = strURL

    myAdapter.Submit

    Is there any way to update the Folder URL for the form in the manifest.xsf so we don't have to enter a new URL in a text box eachtime when promoting the form from say, Dev to QA, or QA to Prod.

    Thanks

     

     

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