Dim xapp As Excel.Application
Dim wbook As Excel.Workbook
Dim WS As Excel.Worksheet
Dim intX As Integer
Dim strResults As String
'Start a new instance of Excel
Set xapp = New Excel.Application
'Create a new workbook
Set wbook = xapp.Workbooks.Add
Set WS = wbook.Worksheets.Add
WS.Name = "Direct"
Dim db As DAO.Database
Set db = CurrentDb()
Dim recSet As DAO.Recordset
Set recSet = db.OpenRecordset("Q_Direct_Job_Orders", dbOpenDynaset)
If recSet.EOF = True Then
recSet.Close
Exit Function
End If
Do While Not recSet.EOF
wks.Range("J" & intEnd) =
Format(CDbl(recSet"Amount")), "$#,##0.00_);($#,##0.00)")
Loop
recSet.Close
xapp.Visible = True
xapp.Quit
'Cleaning up
Set WS = Nothing
Set wbook = Nothing
Set xapp = Nothing