Copy Data between 2 subforms (1 Viewer)

hoochiepoos

New member
Local time
Today, 21:48
Joined
Dec 12, 2018
Messages
8
Hi,


I am trying to duplicate some data to avoid aching fingers. The data would be modified on the purchasing form so it is not true data duplication.


The structure is as follows:
Form for internal use = frmSparesProcessing
subform = frmSubSparesDetail



Form for External use = PurchaseOrderform
subform =OrderDetailsSubform


I have managed to populate the PurchaseOrderform form but only 1 record comes over from frmSubSparesDetail and is inserted into OrderDetailsSubform.



I am a beginner at VBA and I appreciate your kind help.



Code:
Private Sub btnSupplierOrder_Click()

 If Not IsNull(Me![EnquiryNo]) Then

    DoCmd.OpenForm "PurchaseOrdersForm"
    DoCmd.GoToRecord , , acNewRec

      Forms![PurchaseOrdersForm]![CompanyID] = Me![cboSupplierCompany]
      Forms![PurchaseOrdersForm]![OrderInitials] = Me![cboEmployeeID]
     Forms![PurchaseOrdersForm]![JobNumber] = DLookup("[Job Ref]", "[qryMachineRegisterJob]")
      Forms![PurchaseOrdersForm]![SalesPerson] = Me![cboSupplierEmployee]


Dim rs As DAO.Recordset
Forms.PurchaseOrdersForm.SetFocus
    Set rs = Me.frmSubSparesDetail.Form.Recordset

    rs.MoveFirst
    Do While Not rs.EOF()
    With rs
       Forms![PurchaseOrdersForm]![OrderDetailsSubform].Form.ItemDescription = rs!Description
        .MoveNext
        End With
    Loop
    rs.MoveFirst
    Set rs = Nothing
 

theDBguy

I’m here to help
Staff member
Local time
Today, 14:48
Joined
Oct 29, 2018
Messages
21,358
Hi. The simplest way to duplicate records is by using an Append query. So, before you open the second form, try to execute an Append query against its table first. For example, this should duplicate an existing record with ID #1.
Code:
INSERT INTO TableName(Field1,Field2) SELECT Field1,Field2 FROM TableName WHERE ID=1
 

Users who are viewing this thread

Top Bottom