newbie trying to populate Infopath fields - InfoPath Dev
in

InfoPath Dev

newbie trying to populate Infopath fields

Last post 11-28-2012 10:12 AM by Hilary Stoupa. 6 replies.
Page 1 of 1 (7 items)
Sort Posts: Previous Next
  • 11-27-2012 03:28 PM

    newbie trying to populate Infopath fields

    Hi guys,

     So glad I came across this forum, hoping someone can help this newbie out!!

     I am trying to populate fields on an InfoPath form that someone else developed. I am using data from an Access database to populate the fields. I have never worked with InfoPath before.

    So far all I'm able to do is open the InfoPath template (.xsn) file, but I'm not exactly sure how I start populating data in the fields. This is the code I have so far:

        Dim appInfoPath As InfoPath.Application
        Dim docInfoPath As InfoPath.XDocument
        
        
        Set appInfoPath = CreateObject("infopath.Application") 'Create an instance of InfoPath

        Set docInfoPath = appInfoPath.XDocuments.NewFromSolution("N:\Database\Compensation\Working copy\Payment_Request.xsn")

     After looking at the 'Watch' window in Access, I can see the fields (eg, "SAPDocNumber") I want to populate but as I said, not sure what code I need to use to actually do that (see image).

    http://imageshack.us/photo/my-images/834/watchwindow.jpg

    Any help you can give would be really appreciated.

    Cheers

  • 11-27-2012 03:35 PM In reply to

    Re: newbie trying to populate Infopath fields

    Hi - welcome!

    You know if you want your form to query from and submit to an Access DB, you can just base the form off the DB - no code needed there. Or, if you just want to query, you could add a secondary data connection to query the DB. Any particular reason you are taking this approach?

    Hilary Stoupa

  • 11-27-2012 03:50 PM In reply to

    Re: newbie trying to populate Infopath fields

    Hi Hilary,

     Thanks so much for the quick reply.

    I don't want to submit to an Access DB, but rather populate the form based on values in the DB. The form I'm trying to populate is used across the organisation in many different areas. The database I'm using to populate the form is used by a select group of people who use the form for a specific purpose, so I'd rather 'push' the data from the database rather than modifying the form to 'pull' the data.

  • 11-27-2012 05:10 PM In reply to

    Re: newbie trying to populate Infopath fields

    Okay - well, it looks like you are using vbscript? I'm more a managed code girl, so probably won't be a ton of help there - you'll need to get the XPath of the field you want to populate - what version of IP are you using?
    Hilary Stoupa

  • 11-27-2012 05:11 PM In reply to

    Re: newbie trying to populate Infopath fields

    Oh, check this post, the code sample there may help you... http://www.infopathdev.com/forums/p/801/3094.aspx
    Hilary Stoupa

  • 11-27-2012 07:25 PM In reply to

    Re: newbie trying to populate Infopath fields

    Hi Hilary,

    Yes, the link you provided had some examples which have worked for me. However I'm still having a couple of issues

    1) I can't seem to populate fields that have been formatted as a 'list box'. For example, this code works for all non-listbox textboxes:
    docInfoPath.DOM.SelectSingleNode("//my:RequestTypeOther").Text = "Test"
    but when it tries to do that to a textbox that is formatted as a 'list box', nothing happens

    2) at least one field on the form has validation that runs after you exit the field. Is there anyway I can get that validation to run through code?

  • 11-28-2012 10:12 AM In reply to

    Re: newbie trying to populate Infopath fields

    Put an expression box on your form with the value of the field that is bound to the list box. I imagine you are setting the value, but that it is not corresponding to a selection in the list box.

    What is happening with your field with validation? I'd expect the validation to still be triggered if you set the field to an invalid value in your code.

    Hilary Stoupa

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