Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access 2003 Error 91 Object Reference or Variable Not Set XML Import

Status
Not open for further replies.

gino5555

Technical User
Jun 16, 2005
7
US
I am trying to import an XML document and because of how it's set up I already know that an XSLT will not work. I need to import it using the DOMDocument coding. I am trying to learn the code, but have gotten stuck with the first test. This is an example straight out of the book. Here is my code:

===============================================
Private Sub ImportXML_Click()

Dim objDOMDocument As DOMDocument
Dim objXMLDOMElement As IXMLDOMElement

Me.txtFileName = "C:\Documents and Settings\Jaynelle\My Documents\ScottsTreatmentCtr\SCC_XML\20100305_To_8.xml"

Set objDOMDocument = New DOMDocument
objDOMDocument.async = False
objDOMDocument.Load Chr(34) & Me.txtFileName & Chr(34)

Set objXMLDOMElement = objDOMDocument.DocumentElement

MsgBox "objXMLDOMElement is " & objXMLDOMElement.nodeName <-------ERROR IS HERE------>

End Sub
=======================================================

This is on a form and the txtFileName is usually on the form, but have it in the code just for testing.

When the code breaks I can roll over the objXMLDOMDocument and see that it equals "Nothing". I am able to do a direct import of the XML (imports 6 table with no related fields).

========================================================

Object References: I've added a few more than I usually use just to make sure it wasn't something there:

Visual Basic for Applications
Microsoft Access 11.0 Object Library
Microsoft DAO 3.6 Object Library
OLE Automation
Microsoft ActiveX Data Objects 2.8 Library
Microsoft ADO Ext. 2.8 for DDL and Security
Microsoft Jet and Replication Objects 2.6 Library
Microsoft Office 12.0 Object Library
Microsoft XML, v6.0
Microsoft Data Access Components Installed Version

==========================================================

Thanks!

JPR
 
[1] Though acceptable,
>Me.txtFileName = "C:\Documents and Settings\Jaynelle\My Documents\ScottsTreatmentCtr\SCC_XML\20100305_To_8.xml"
better this with more rigor.
[tt]Me.txtFileName[blue].text[/blue] = "C:\Documents and Settings\Jaynelle\My Documents\ScottsTreatmentCtr\SCC_XML\20100305_To_8.xml"[/tt]

[2] The problem.
[tt]> [/tt]objDOMDocument.Load Chr(34) & Me.txtFileName & Chr(34)
[tt] objDOMDocument.Load Me.txtFileName[red].text[/red][/tt]

[2.1] Do you mean straight from the book? which? with those chr(34) non-sense and textbox reference load. If you want a bit of obscurity, enclose it by parentheses!
[tt] objDOMDocument.Load [highlight]([/highlight]Me.txtFileName[highlight])[/highlight][/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top