mdschuetz
Nerd Incognito
- Local time
- Today, 15:40
- Joined
- Oct 31, 2007
- Messages
- 49
Can anyone explain to me what I'm doing wrong with this?
I've been at this problem for over a week and its driving me mad. Nothing I try works.
I have a subform within a form.
This code lies in the main form on a command button cmdQC9 in an on_Click procedure.
If a value greater than 0 is present in the textbox on the subform I want to move cell data from both forms to an excel spreadsheet.
The subform is a datasheet.
The textbox UnitsReceived
Will someone please explain what I'm doing wrong?
Thanks,
Marty
I've been at this problem for over a week and its driving me mad. Nothing I try works.
I have a subform within a form.
This code lies in the main form on a command button cmdQC9 in an on_Click procedure.
If a value greater than 0 is present in the textbox on the subform I want to move cell data from both forms to an excel spreadsheet.
The subform is a datasheet.
The textbox UnitsReceived
Will someone please explain what I'm doing wrong?
Thanks,
Marty
Code:
Private Sub cmdQC9_Click()
Dim strIDD as String
strIDD = [Purchase Orders Subform].Form!UnitsReceived
If CurrentDb.OpenRecordset(strIDD).Value > 0 THEN
Dim objXxL As Excel.Application
Dim objWxB As Excel.Workbook
Dim objWxS As Excel.Worksheet
Set objXxL = Excel.Application
Set objWxB = objXxL.Workbooks.Open("\\mypath.xls")
Set objWxS = objWxB.Worksheets("Form")
With objWxS
.Cells(6, 3).Value = Me.txtTD
.Cells(13, 13).Value = Me.txtYes
.Cells(13, 16).Value = Me.txtNo
.Cells(10, 4).Value = Me.PurchaseOrderNumber
.Cells(8, 3).Value = Me.cboSupplierID.Column(1)
.Cells(8, 19).Value = Me.cboAccount.Column(1)
.Cells(10, 9).Value = Me.cboPJO.Column(1)
.Cells(13, 31).Value = Me.cboInspect.Column(0)
Dim xx As Integer
xx = 38
[Purchase Orders Subform].Form.Recordset.MoveFirst
While Not [Purchase Orders Subform].Form.Recordset.EOF
.Cells(xx, 2).Value = [Purchase Orders Subform].Form!UnitsRecieved
.Cells(xx, 4).Value = [Purchase Orders Subform].Form!PartNumber & " -" & [Purchase Orders Subform].Form!ItemDescription
.Cells(xx, 15).Value = [Purchase Orders Subform].Form!UnitPrice
[Purchase Orders Subform].Form.Recordset.MoveNext
xx = xx + 1
Wend
End With
objXxL.Visible = True
objXxL.Workbooks.Close
End If
End Sub