From: Boon on
Hi,

I am trying to export a select query to a XML file but didn't find any
success.

Here is the code I use......

Application.ExportXML ObjectType:=acExportTable, DataSource:="ForXML",
DataTarget:="VendorData.xml"


The ForXML is the select query. I noticed that when I export from a table it
works just fine.

How can I export from a query?

thanks!
Boon



From: Dirk Goldgar on
"Boon" <boonyawat.la-ongthong(a)cnh.com> wrote in message
news:OfBCr8G8KHA.5476(a)TK2MSFTNGP06.phx.gbl...
> Hi,
>
> I am trying to export a select query to a XML file but didn't find any
> success.
>
> Here is the code I use......
>
> Application.ExportXML ObjectType:=acExportTable, DataSource:="ForXML",
> DataTarget:="VendorData.xml"
>
>
> The ForXML is the select query. I noticed that when I export from a table
> it works just fine.
>
> How can I export from a query?


If you're exporting a query, use acExportQuery, not acExportTable.

--
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)

From: Boon on
thanks.

If I do in VBA, and have and SQL statement like "SELECT ......"

Can I export this aswell?

"Dirk Goldgar" <dg(a)NOdataSPAMgnostics.com.invalid> wrote in message
news:uG7ofBH8KHA.4604(a)TK2MSFTNGP04.phx.gbl...
> "Boon" <boonyawat.la-ongthong(a)cnh.com> wrote in message
> news:OfBCr8G8KHA.5476(a)TK2MSFTNGP06.phx.gbl...
>> Hi,
>>
>> I am trying to export a select query to a XML file but didn't find any
>> success.
>>
>> Here is the code I use......
>>
>> Application.ExportXML ObjectType:=acExportTable, DataSource:="ForXML",
>> DataTarget:="VendorData.xml"
>>
>>
>> The ForXML is the select query. I noticed that when I export from a table
>> it works just fine.
>>
>> How can I export from a query?
>
>
> If you're exporting a query, use acExportQuery, not acExportTable.
>
> --
> Dirk Goldgar, MS Access MVP
> Access tips: www.datagnostics.com/tips.html
>
> (please reply to the newsgroup)
>


From: Boon on
More finding.

I found out that I cannot use parameterized Select Query to do XMLExport.

Any suggesstion is appreciated.


"Boon" <boonyawat.la-ongthong(a)cnh.com> wrote in message
news:uvBgKor8KHA.4600(a)TK2MSFTNGP02.phx.gbl...
> thanks.
>
> If I do in VBA, and have and SQL statement like "SELECT ......"
>
> Can I export this aswell?
>
> "Dirk Goldgar" <dg(a)NOdataSPAMgnostics.com.invalid> wrote in message
> news:uG7ofBH8KHA.4604(a)TK2MSFTNGP04.phx.gbl...
>> "Boon" <boonyawat.la-ongthong(a)cnh.com> wrote in message
>> news:OfBCr8G8KHA.5476(a)TK2MSFTNGP06.phx.gbl...
>>> Hi,
>>>
>>> I am trying to export a select query to a XML file but didn't find any
>>> success.
>>>
>>> Here is the code I use......
>>>
>>> Application.ExportXML ObjectType:=acExportTable, DataSource:="ForXML",
>>> DataTarget:="VendorData.xml"
>>>
>>>
>>> The ForXML is the select query. I noticed that when I export from a
>>> table it works just fine.
>>>
>>> How can I export from a query?
>>
>>
>> If you're exporting a query, use acExportQuery, not acExportTable.
>>
>> --
>> Dirk Goldgar, MS Access MVP
>> Access tips: www.datagnostics.com/tips.html
>>
>> (please reply to the newsgroup)
>>
>
>


From: Dirk Goldgar on
"Boon" <boonyawat.la-ongthong(a)cnh.com> wrote in message
news:uvBgKor8KHA.4600(a)TK2MSFTNGP02.phx.gbl...
> thanks.
>
> If I do in VBA, and have and SQL statement like "SELECT ......"
>
> Can I export this aswell?


You mean, export the output of a SQL statement directly, without it being
embodied in a stored query or other Access object? I don't think so. A
workaround would be to have a stored query that you use for export, and
dynamically set its .SQL property to your SQL statement, then export it.
Something like:

Dim strSQL As String

strSQL = "SELECT Foo FROM Bar WHERE Baz > 0"

CurrentDb.QueryDefs("qryExport").SQL = strSQL

Application.ExportXML ObjectType:=acExportQuery, _
DataSource:="qryExport", _
DataTarget:="MyExportedQuery.xml"

Note: in the above, I'm assuming that qryExport has already been created.

--
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)