Access to an Access DB #2 - InfoPath Dev
in

InfoPath Dev

Access to an Access DB #2

Last post 05-04-2006 06:48 AM by Jerry. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 05-01-2006 02:17 PM

    • Jerry
    • Not Ranked
    • Joined on 04-17-2006
    • USA
    • Posts 14

    Access to an Access DB #2

    My original question was about how to read an Access database and pull data from it and insert the data into specific fields in the InfoPath form. Matt Faus, gave me the following link, and I was able to follow the instructions; however, something appears to be wrong with the code for the 'Button' called View Details.

    http://infopathdev.com/howto/tutorials/default.aspx?i=0bb37b4de44348408680a53a449f2353

    I get an error message which says... "Object required". There must be something wrong with the code? Line 24... where it starts out as "oQueryID.text = eventObj.Source.selectSingleNode...

    // The following function handler is created by Microsoft Office InfoPath.
    // Do not modify the name of the function, or the name and number of arguments.
    //=======
    function btnViewDetail::OnClick(eventObj){var oQueryId = XDocument.DOM.selectSingleNode
    ("/dfs:myFields/dfs:queryFields/q:Customers/@CustomerID" );
    oQueryId.text = eventObj.Source.selectSingleNode("@CustomerID").text;
    XDocument.Query();
    XDocument.View.SwitchView("Detail");}

    What am I doing wrong?

  • 05-01-2006 06:46 PM In reply to

    Re: Access to an Access DB #2

    Are you trying to recreate the form from the tutorial? If you followed the steps exactly, the code should work (I still have my XSN that I made for that HowTo if you want it). Or are you trying to apply the HowTo to your own situation?

    Either way, it sounds like you are getting an XPath error so that selectSingleNode returns a null object. As a quick test update your code for the following and tell me where the error occurs:

    // The following function handler is created by Microsoft Office InfoPath.
    // Do not modify the name of the function, or the name and number of arguments.
    //=======
    function btnViewDetail::OnClick(eventObj)
    {
    var oQueryId = XDocument.DOM.selectSingleNode
    ("/dfs:myFields/dfs:queryFields/q:Customers/@CustomerID" );
    XDocument.UI.Alert( oQueryId.text );
    XDocument.UI.Alert( eventObj.Source.selectSingleNode("@CustomerID").text );
    oQueryId.text = eventObj.Source.selectSingleNode("@CustomerID").text;
    XDocument.Query();
    XDocument.View.SwitchView("Detail");
    }

    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 05-02-2006 06:58 AM In reply to

    • Jerry
    • Not Ranked
    • Joined on 04-17-2006
    • USA
    • Posts 14

    Re: Access to an Access DB #2

    Hi Matt.... I'm just trying to execute your tutorial exactly. I made the code modification as you suggested, but am still getting the error. Line 27.... Object Required. Below is line 27 of the code..

    XDocument.UI.Alert( eventObj.Source.selectSingleNode("@CustomerID").text );
  • 05-02-2006 07:11 AM In reply to

    Re: Access to an Access DB #2

    This could mean only one thing: That your XPath is failing in the selectSingleNode() function.

    Here are some tips for debugging the XPath, all of these can be examined via Alert()
    eventObj.Source.nodeName
    eventObj.Source.nodeType
    eventObj.Source.parentNode.nodeName
    eventObj.Site.nodeName


    Also, be sure to look at the context of the button to make sure that the XPath is appropriate. I hope this helps, let us know if there are any more problems!
    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 05-04-2006 06:48 AM In reply to

    • Jerry
    • Not Ranked
    • Joined on 04-17-2006
    • USA
    • Posts 14

    Re: Access to an Access DB #2

    Sorry Matt.... since I'm new to Infopath and XML, I have no idea as to what I'm looking for by using the alert functions you suggested in your last reply. I checked, double and triple checked the steps of your tutorial, but it does not work. I still get the error message
    "Object required". Referring to the link below... regarding populating fields from a drop-down selection...this is what I want to do, but in this reference the data to be populated is in the XML code, not a DB. I do not want to have to key the data into the XML code, instead I want to pull it out of the DB. In the example below, what would I have to change to access the database?

    http://infopathdev.com/howto/tutorials/default.aspx?i=9111ef580f95479890fc18fb2c5bac85
Page 1 of 1 (5 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.