This is the relevant portion of the procedure:
Expand|Select|Wrap|Line Numbers
- Private Sub GenerateExplodedBOM()
- 'On Error GoTo Err_Handler
- Dim appXL As Object
- Dim wbBOM As Object
- Dim rs As New adodb.Recordset
- Set appXL = CreateObject("Excel.Application")
- appXL.Visible = True
- Set wbBOM = appXL.workbooks.Add
- wbBOM.Activate
- wbBOM.sheets.Add Before:=wbBOM.sheets(1)
- wbBOM.sheets(1).name = Forms!PDC_home!ItemNum & " Exploded BOM"
- wbBOM.sheets(1).Select
- rs.Open "SELECT * FROM tblProduct WHERE ItemNum = '" & _
- Forms!PDC_home!ItemNum & "'", CurrentProject.Connection, _
- adOpenForwardOnly
- With wbBOM.sheets(1)
- .cells(1, 1).value = rs!ItemNum
- .cells(1, 2).value = rs!PurchaseDescription
- .cells(1, 3).value = "1"
- .cells(1, 4).value = CCur(rs!BOMtotal)
- End With
- rs.Close
- Set rs = Nothing