Lobb
asked on
Rename a table when importing from XML using Access VBA
Hi experts,
I have created a form in access that imports an XML file to my database. I would like to rename the table every time I import the XML file. Heres my current code. How would I go about renaming the XML table to 'note' every time I import it?
Thanks
I have created a form in access that imports an XML file to my database. I would like to rename the table every time I import the XML file. Heres my current code. How would I go about renaming the XML table to 'note' every time I import it?
Private Sub Command10_Click()
Dim File As Variant
File = GetFile()
If IsNull(File) Then
MsgBox "Nothing was selected", vbOKOnly
Else
Me.FName = File
Application.ImportXML _
DataSource:=Me.FName, _
ImportOptions:=acStructureAndData
End If
End Sub
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Is it failing on the code I added, or on the import statement?
How are you selecting the file to import? Are you using a file dialog?
When you use ImportXML, it *should* create a table having the same name as the file that you are importing (ie: "test.XML" will automatically import into a table called "test"). So if you are browsing to a file, the table created will be given the same name as the file you browse to.
If possible, please post a sample copy of your database - including just the relevant form/tables/etc, and with any personal or sensitive data removed, and also post a sample XML file.
How are you selecting the file to import? Are you using a file dialog?
When you use ImportXML, it *should* create a table having the same name as the file that you are importing (ie: "test.XML" will automatically import into a table called "test"). So if you are browsing to a file, the table created will be given the same name as the file you browse to.
If possible, please post a sample copy of your database - including just the relevant form/tables/etc, and with any personal or sensitive data removed, and also post a sample XML file.
ASKER
I don't know the table name or file name of the files that I am uploading. I just hope to rename the table every time I upload an xml file to the same name.