Results 1 to 3 of 3
  1. #1
    Star Lounger
    Join Date
    May 2003
    Location
    Pennsylvania, USA
    Posts
    55
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exporting to XML (Access 2000)

    Can Access export data as an XML file? If so, could anyone please direct me to a tutorial that tells how to do it.

    Thanks.

    Don.

  2. #2
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,624
    Thanks
    3
    Thanked 60 Times in 60 Posts

    Re: Exporting to XML (Access 2000)

    In Access 2002 it is relatively simple - XML is one of the file types you can export a table, or the results of a query to. In 2000, the situation is a bit more limited - unfortunately I don't have a 2000 version to play with at the moment. Office 2000 has some basic capability to save data in an HTML format, and there are some XML statements used in doing that in order to be able to round-trip documents. And at that point I've exhausted my knowledge - hopefully someone else can elaborate on 2000 capabilities.
    Wendell

  3. #3
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Exporting to XML (Access 2000)

    In Access 2000, you can "persist" a recordset as an XML file, if that's what you're looking for. You have to use an ADO recordset. Here's a sample routine to persist a recordset to XML format. This is some old code from a demo project, so don't expect too much from it.

    <pre>Public Function PersistRecordSet(ByVal strSrc As String, _
    ByVal strRecSetName As String) _
    As Boolean
    ' Created by Charlotte Foust
    ' last modified 2/19/2001
    ' Persists an ADO recordset to current project path as XML
    On Error GoTo Proc_err
    Dim rst As ADODB.Recordset
    Dim errCurr As ADODB.Error
    Dim colErrs As ADODB.Errors
    Dim strSQL As String
    Dim strPath As String
    ' Open a recordset against the passed
    ' table using the connection of the currently
    ' open project.

    If InStr(strSrc, "SELECT ") = 1 Then
    'strSrc is a query
    strSQL = strSrc
    Else
    'strSrc is a table or query name
    strSQL = "SELECT * FROM " & strSrc
    End If 'InStr(strSrc, "SELECT ") = 1

    Set rst = New ADODB.Recordset
    With rst
    .ActiveConnection = CurrentProject.Connection
    'initialize the errors collection on the connection
    'and clear any existing errors
    Set colErrs = rst.ActiveConnection.Errors
    colErrs.Clear

    .CursorType = adOpenKeyset
    .LockType = adLockOptimistic
    .Open strSQL

    ' Save the recordset using the
    ' XML format.
    If InStr(strRecSetName, "") <> 0 Or _
    InStr(strRecSetName, ":") <> 0 Then
    strPath = strRecSetName
    Else
    strPath = CurrentProject.Path
    If Right(strPath, 1) <> "" Then
    strPath = strPath & "" & strRecSetName
    Else
    strPath = strPath & strRecSetName
    End If 'Right(strPath, 1) <> ""
    End If 'InStr(strRecSetName, "") <> 0 Or _
    InStr(strRecSetName, ":") <> 0
    'kill the file if it already exists
    On Error Resume Next
    Kill strPath
    'persist the recordset
    .Save strPath, adPersistXML
    End With 'rst
    PersistRecordSet = True
    Proc_exit:
    'cleanup and exit
    On Error Resume Next
    Set rst = Nothing
    Exit Function
    Proc_err:
    'handle ADO errors
    If colErrs.Count > 0 Then
    For Each errCurr In colErrs
    MsgBox errCurr.Number & "--" & errCurr.Description
    Next errCurr
    colErrs.Clear
    End If
    'exit the procedure
    Resume Proc_exit
    End Function</pre>

    Charlotte

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •