如何在访问vba中将访问表导出到XML

时间:2017-01-04 11:09:37

标签: xml access-vba access

我正在尝试从Access表导出XML文件,我创建了用于将访问表转换为.txt文件('$'分隔)的代码,我是否可以更改此代码以将访问表转换为.XMl或者我需要为此再次编码,
我有以下代码:

sSql = ""
sSql = "SELECT * from tbl_exportFile where Upload_date=cdate(#" & Format(CDate(txtToDayDate), "dd-MMM-yyyy") & "#)"

If rs.State = 1 Then rs.Close
rs.Open sSql, con, adOpenKeyset, adLockOptimistic

If rs.RecordCount > 0 Then
    If FE.FolderExists(Application.CurrentProject.Path & "\Reports\") = False Then
       FE.CreateFolder (Application.CurrentProject.Path & "\Reports\")
    End If

    F_Name1 = Application.CurrentProject.Path & "\Reports\" & strReportFileName & ".txt"

    Set TSWrite = FE.OpenTextFile(F_Name1, ForWriting, True)

    strData = ""
    strData = strData & "noOfShippingBills$"
    strData = strData & "noOfInvoices$"
    strData = strData & "exportAgency$"

    TSWrite.WriteLine strData

    Do While rs.EOF = False
        strData = ""
        strData = strData & IIf(IsNull(rs.Fields![noOfShippingBills]), "", rs.Fields![noOfShippingBills]) & "$"
        strData = strData & IIf(IsNull(rs.Fields!noOfInvoices), "", rs.Fields!noOfInvoices) & "$"
        strData = strData & IIf(IsNull(rs.Fields!exportAgency), "", rs.Fields!exportAgency) & "$"
            TSWrite.WriteLine strData
        rs.MoveNext
    Loop    

    TSWrite.Close

    DoCmd.Hourglass (False)

    MsgBox "Export file Report Generated Successfully.", vbInformation, "RBI Macro"
Else
    MsgBox "Data not found to generate Import file Report.", vbInformation, "RBI Macro"
    DoCmd.Hourglass (False)
End If

请帮助我,提前谢谢!!

0 个答案:

没有答案