By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,098 Members | 1,116 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,098 IT Pros & Developers. It's quick & easy.

Application.ImportXML Fatal Error; Causes? Way Around?

P: n/a
All -

2 questions, the answer to either one having the possibility of making
the other a moot point:

1. I have a DB with a form that serves as a GUI to let the user browse
for an XML file and import it, and I can't get Access to overwrite the
tables when it finds them in existence. Can anyone tell me how to make
this happen? I can't get the "OtherFlags:=1" option to work -

I've even tried using just the code from MSDN, but I can't even get
this to work;

Application.ImportXML _
DataSource:="C:\XMLData\Invoices.xml", _
OtherFlags:=1

Whenever I try to run or compile it, Access shows the error "Named
argument not found." Here's the line I'm currently using, without
the option:

Application.ImportXML [MyXMLFile], acStructureAndData

(Full code below to explain [MyXMLFile])

Am I missing something? If I should be "naming " (Dimming?)
OtherFlags, how? Any one know what the finished line should look like?
I've tried many, many variations.
2. I can use the form successfully a few times (deleting the tables
manually), until maybe the 4th or 5th time I try the process, and
Access crashes and rebuilds the DB. Then the form won't work any more,
unless I create a new DB and import all my forms, modules, etc. Any
ideas why?

I don't know if this is because I have to delete the newly created
tables manually...but I'm trying to eliminate all possible sources of
"corruption."

Here's the full code I'm using, built from several sources. I've
included more than just the Application.Import line because I'm using a
control to get [MyXMLFile], the name of the XML file.
__________________________________________________ _________________

Option Explicit

Dim MyXMLFile As String
__________________________________________________ _________________

Private Sub Select_Button_Click()
Dim strInputFileName As Variant

strInputFileName = FileOpenSave(True)

If Len(strInputFileName) > 0 Then
MyXMLFileTxt = strInputFileName
MyXMLFile = strInputFileName
End If

End Sub
__________________________________________________ _________________

Private Function FileOpenSave(fOpen As Integer) As Variant
Dim ofn As tagOPENFILENAME
Dim strFilter As String
Dim lngFlags As Long

strFilter = acbAddFilterItem(strFilter, "XML Files (*.xml)",
"*.XML")

FileOpenSave = acbCommonFileOpenSave(Filter:=strFilter, _
InitialDir:="\\B3\CDW\Information Solutions\2 -
Documentation\DocuVisn\Corporate Data Warehouse")

OK_Button.Visible = True
End Function
__________________________________________________ _________________

Private Sub OK_Button_Click()

If IsNull([MyXMLFile]) Then
Beep
MsgBox "Please click the 'Select...' button to browse to a
DocuVisn XML file.", 64, "Completion Message"

Else
DoCmd.Hourglass True
DoCmd.Echo True, "Now Importing DocuVisn XML File...Please
Wait"

'Import Stuff

Application.ImportXML [MyXMLFile], acStructureAndData

DoCmd.Echo True
DoCmd.Hourglass False

Beep

MsgBox "The XML file has been successfully imported. Now open
'CDW Reports Data Entry' and complete the Report Verification ", 64,
"Completion Message"

DoCmd.Close acForm, "FRM_Import_DV_XML"

End If

End Sub

__________________________________________________ _________________

I'd rather not create/delete/create/delete over and over again, because
I think it may be what's causing problems with the stability of my
DB. Not sure if this is the case - maybe someone knows of or can
spot something else that could be causing the problem.

Thanks.

Patrick

Nov 13 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.