VBS Code to update Access Database - InfoPath Dev
in

InfoPath Dev

VBS Code to update Access Database

Last post 07-15-2008 04:52 AM by Hilary Stoupa. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 07-15-2008 04:22 AM

    VBS Code to update Access Database

    First, this is my first post! So here are a few items that may make it apparent why I am trying to take this approach.

    I do not have sharepoint and will not be able to get it. I have to move my program off of a web server because we are not allowed to use one. They still want me to make it work and I really do not give up on something. I thought I could use vb script on the form and just use that to update a database on the file share.

    Sub XDocument_OnSubmitRequest(eventObj)

    Dim db1, dba, rs1, qry, tp1

    set db1 = CreateObject("ADODB.Connection")

    set rs1 = CreateObject("ADODB.Recordset") dba = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\\Snnsvr042\Apps\C1200APPS\databases\DashBoardData.mdb"

    db1.Open dba

    tp1 = XDocument.DOM.selectSingleNode("my:DocumentNumber").nodeValue

    XDocument.UI.Alert(tp1)

    qry = "insert into ContractsXML ([Document Number]) Values ('" & docnum & "')"

    set rs1 = db1.Execute(qry)

    if err.number <> 0 then

    eventObj.ReturnStatus = True

    else

    eventObj.ReturnStatus = False

    end if

    End Sub

    So, this so far seems like it should work similar to other systems I use this approach in. However, I receive an error on the line:

    tp1 = XDocument.DOM.selectSingleNode("my:DocumentNumber").nodeValue

    The error just says "Object Required" even though the node is correct. Any ideas or other thoughts would be appreciated.

  • 07-15-2008 04:33 AM In reply to

    Re: VBS Code to update Access Database

    Hello, and welcome! Try this: Set tp1 = XDocument.DOM.selectSingleNode("my:DocumentNumber") XDocument.UI.Alert(tp1.text) and see if you get your node's text in your alert box.....
    Hilary Stoupa

  • 07-15-2008 04:38 AM In reply to

    Re: VBS Code to update Access Database

    Funny! I realized that I forgot to add the .text at the end just before I got your response! However, the database updated just fine with this test, but Infopath reported that it did not because the provider returned an error. I am not sure how to prevent this from happening as the update went just fine! I do not want the users to think there is a problem!

  • 07-15-2008 04:44 AM In reply to

    Re: VBS Code to update Access Database

    I am such a goober! I had my error check code reversed and switched the True False flags. Once I fixed this, it works like a charm!! Yee Haw!!

  • 07-15-2008 04:52 AM In reply to

    Re: VBS Code to update Access Database

    Cool -- I do that kind of stuff too -- code dyslexia.
    Hilary Stoupa

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