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!

Output Query to XML button 1

Status
Not open for further replies.

Triacona

Technical User
Jun 11, 2009
462
GB
Dear All,

Thanks for a great forum.

My problem is as such.

I have a form MainScreen
It has a fields, txtPath which contains the path to where it should save the document, sFullPath which is the ListCP and txtPath combined.

I am trying to export the query chosen in the list (ListCP) to XML format

I have only succeeded in exporting the query to xls format, as below.


Code:
Private Sub CpOutputQueryToXML_Click()

Dim stDocName As String
Dim FullPath As String
stDocName = ListCP
sFullPath = txtPath & ListCP & ".xls"

    DoCmd.OutputTo acOutputQuery, stDocName, acFormatXLS, sFullPath, True
 

End Sub

What do I need to change in order to export in to XML?

Thank you in advance for your help![smile]

Thank you,

Kind regards

Triacona
 
What about the Application.ExportXML method ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Dear PHV,

Thank you for your help[smile]

How would I use that?
Code:
Private Sub CpOutputQueryToXML_Click()

Dim stDocName As String
Dim FullPath As String

stDocName = ListCP
sFullPath = txtPath & ListCP & ".xls"    

   DoCmd.Application.ExportXML acOutputQuery, stDocName, acFormatXLS, sFullPath, True 

End Sub

Thanks in advance for your help[smile]

Thank you,

Kind regards

Triacona
 
A starting point:
Code:
Private Sub CpOutputQueryToXML_Click()
Application.ExportXML acExportQuery, Me!ListCP, Me!txtPath & Me!ListCP & ".xlm"
End Sub

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Dear PHV,

Thank you in works brilliantly have a STAR!

What does the Me! stand for?

Also do you know of any XML readers that I can view an XML with?

I try to open the exported XML in Excel but it says it has an invalid character?

I corrected your code is this correct? Or is this why I cann't open it in Excel?
Code:
Private Sub CpOutputQueryToXML_Click()

Application.ExportXML acExportQuery, Me!ListCP, Me!txtPath & Me!ListCP & [b][highlight]".xml"[/highlight][/b]

End Sub

Thank you very much[2thumbsup]


Thank you,

Kind regards

Triacona
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top