I need to write data to a table from a sub form, so I using a Form.RecordSetClone.
On the subform I have a combo box called "cboInvoiceId" and I need the data in column 4
This is what I have
!SupplierReference = rstProductsToReturn!cboInvoiceId.Column(3) returns the run time error 3265 - Item not found in this collection.
Is the syntax wrong?
How do I refer to cboInvoiceId.Column(3)?
Many thanks
On the subform I have a combo box called "cboInvoiceId" and I need the data in column 4
This is what I have
Code:
Dim db As DAO.Database
Dim intCustomerReturnsShipmentsId As Long
Dim rst As DAO.Recordset
Dim rstProductsToReturn As DAO.Recordset
Set db = CurrentDb
Set rst = db.OpenRecordset("Select CustomerReturnsShipmentsId from tblCustomerReturnsShipments where CustomerReturnsShipmentsDirection = 2 and CustomerReturnsShipmentsClosed = False and SupplierId = " & Me.cboCustomerReturnsSupplierId)
If rst.RecordCount = 0 Then 'Create New Shipment
With rst
.AddNew
!SupplierId = Me.cboCustomerReturnsSupplierId
!CustomerReturnsShipmentsDirection = 2
intCustomerReturnsShipmentsId = rst!CustomerReturnsShipmentsId
.Update
End With
Else
intCustomerReturnsShipmentsId = rst!CustomerReturnsShipmentsId
End If
Set rst = db.OpenRecordset("Select * from tblCustomerReturnsShipmentsProducts where 1 =0")
Set rstProductsToReturn = Me.frmCustomerProductReturnProducts.Form.RecordsetClone
With rstProductsToReturn
.MoveLast
.MoveFirst
Do Until .EOF
With rst
.AddNew
!CustomerReturnsShipmentsId = intCustomerReturnsShipmentsId
!CustomerReturnsProductsId = rstProductsToReturn!CustomerReturnsProductsId
'!CustomerReturnsId = rstProductsToReturn!CustomerReturnsId
!CustomerReturnsShipmentsProductsQuantity = rstProductsToReturn!CustomerReturnsProductsQuantity
!SupplierReference = rstProductsToReturn!cboInvoiceId.Column(3)
.Update
End With
.MoveNext
Loop
End With
Is the syntax wrong?
How do I refer to cboInvoiceId.Column(3)?
Many thanks