Martyh
Registered User.
- Local time
- Today, 17:29
- Joined
- May 2, 2000
- Messages
- 196
Hi,
I have "concocted" a way to get an XML file exported. See below. However, I am wondering whether this is the most efficient way of doing that. Any advice would be welcome. BTW I'm not quite finished with ObjectExists (qrytoWebTrainingXML must exists)!
I have "concocted" a way to get an XML file exported. See below. However, I am wondering whether this is the most efficient way of doing that. Any advice would be welcome. BTW I'm not quite finished with ObjectExists (qrytoWebTrainingXML must exists)!
Code:
Private Sub cmdToWeb_Click()
Dim xmlPath As String
Dim dbs As Database, qdf As QueryDef, strSQL As String
On Error GoTo Err_cmdToWeb_Click
Set dbs = CurrentDb
If ObjectExists(1, "qrytoWebTrainingXML") Then DoCmd.DeleteObject acQuery, "qrytoWebTrainingXML"
strSQL = _
"SELECT tblTraining.TrainingID, tblTraining.TrainingCoordinator, " _
& "tblTraining.Title, tblTraining.TrainingDate, tblTraining.DateFrom, " _
& "tblTraining.DateTo, tblTraining.RegCutoffDate, relAreas.AreaCode " _
& "FROM tblTraining INNER JOIN relAreas ON tblTraining.AreaID = relAreas.AreaID " _
& "WHERE (((tblTraining.TrainingID)= " & Me.TrainingID & "));"
Set qdf = dbs.CreateQueryDef("qrytoWebTrainingXML", strSQL)
'openQueryDef
xmlPath = CurrentProject.Path & "\XML\" & TrainingID & ".xml"
'Debug.Print xmlPath
Application.ExportXML acExportQuery, "qrytoWebTrainingXML", xmlPath
Exit_cmdToWeb_Click:
Exit Sub
Err_cmdToWeb_Click:
MsgBox err.Description
Resume Exit_cmdToWeb_Click
End Sub
Public Function ObjectExists(xNumber As Integer, strObj As String) As Boolean
ObjectExists = True
End Function