none
Cannot Export one record from the table or qry to XML. RRS feed

  • Question

  • Hi guys, I am trying to export one record from table or from qry.

    I am using folloowing code:

          Application.ExportXML ObjectType:=acExportQuery, _
                          DataSource:="qryNW", _
                          DataTarget:="C:\DB\Customer.XML", _
                          WhereCondition:="[OrderNumber] = " & txtOrderNumber.Value

    This code should work, but it's not create XML file. If I am not using WhereCondition, it is creating XML file, but it exporting whole table. 

    Can someone please help to understand where is a problem and why I cannot export only one record by criteria I put in Where? 

    Thank you. 

    Monday, February 12, 2018 10:21 PM

All replies

  • Hello DanieMetor,

    >>This code should work, but it's not create XML file.

    What do you mean not creating XML file? Did you ever get any error message? If yes, please share us the error message.

    Is OrderNumber a Text type field? As usually, we often define an OrderNumber as text field so it could be format as specific format. If the OrderNumber in your table is also a text field, you need add single quote around it.

    Such as 

       Application.ExportXML ObjectType:=acExportQuery, _
                          DataSource:="qryNW", _
                          DataTarget:="C:\DB\Customer.XML", _
                          WhereCondition:="[OrderNumber] = '" & txtOrderNumber.Value & "'"

    Best Regards,

    Terry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, February 13, 2018 1:44 AM