I try the END and I cant get excel to unload form memory.
here is my code can someone look at it anf tell me what I did wrong.
Thank you .
Option Compare Database
Dim xlapp As Excel.Application
____________________________________________________________
Private Sub cmd_8_rpt_Click()
On Error GoTo Err_cmd_8_rpt_Click
Dim xlwb As Excel.workbook
Dim sheet As Excel.Worksheet
Dim Db As DAO.Database
Dim rs1 As DAO.Recordset
Dim currentvalue As Variant
Dim currentfield As Variant
Dim workbook As Object
Set Db = CurrentDb()
Set rs1 = Db.OpenRecordset("8tranposed", dbOpenDynaset)
Set xlapp = New Excel.Application
Set xlwb = xlapp.Workbooks.Open("book1.xls"
Set sheet = xlapp.ActiveWorkbook.Sheets(1)
' first clear the old values out.
Rows("14:23"

.Select
Selection.ClearContents
Rows("25:26"

.Select
Selection.ClearContents
Rows("28:31"

.Select
Selection.ClearContents
Rows("33:35"

.Select
Selection.ClearContents
Rows("6:12"

.Select
Selection.ClearContents
j = 14
Do While Not rs1.EOF
For z = 0 To rs1.Fields.Count - 1
currentfield = rs1(z)
If currentfield = "project_number" Then
sheet.Cells(6, 1).Value = "Project Number: " & rs1.Fields(1)
End If
If currentfield = "project_name" Then
sheet.Cells(7, 1).Value = "Project Name: " & rs1.Fields(1)
End If
If currentfield = "location" Then
sheet.Cells(8, 1).Value = "Location: " & rs1.Fields(1)
End If
If currentfield = "prepared_by" Then
sheet.Cells(9, 1).Value = "Prepared By: " & rs1.Fields(1)
End If
If currentfield = "prepared_date" Then
sheet.Cells(10, 1).Value = "Prepared Date: " & rs1.Fields(1)
End If
If currentfield = "checked_by" Then
sheet.Cells(11, 1).Value = "Checked By:" & rs1.Fields(1)
End If
If currentfield = "checked_date" Then
sheet.Cells(12, 1).Value = "Checked By: " & rs1.Fields(1)
End If
Next z
rs1.MoveNext
j = j + 1
Loop
' this prints out the whole workbook.
' Sheets.Application.ActiveSheet.PrintOut
'Sheets.Application.ActiveSheet.PrintPreview
xlapp.Visible = True
xlwb.ActiveSheet.PrintOut , , , True
sheet.Application.ActiveWorkbook.Save
sheet.Application.ActiveWorkbook.Close
xlapp.Quit
Set xlapp = Nothing
Set xlwb = Nothing
Set sheet = Nothing
Set Db = Nothing
Set rs1 = Nothing
END
Exit_cmd_8_rpt_Click:
Exit Sub
Err_cmd_8_rpt_Click:
MsgBox Err.Description
Resume Exit_cmd_8_rpt_Click
End Sub