Starlays
Starlays

Reputation: 1109

Add multiple records from subform to main form Access 2010

Is it possible to add multiple data that has been selected from a subform to the main form?

Subform data to main form

Upvotes: 0

Views: 296

Answers (2)

mememe
mememe

Reputation: 16

To select data it is better to use a listfield and then copy the data with a VB program in the table:

set rs1=currendb.openrecordset ("NAME OF TABLE)
For Z = 0 To Me.ListField.ListCount - 1
    If Me.ListField.Selected(Z) = True Then
        Rs1.addnew 
        rs1!field1 = Me.LisField.Column(0, Z)
        rs1!field2 = Me.LisField.Column(1, Z)     
    End If
next z

Upvotes: 0

Andre
Andre

Reputation: 27634

Form.SelTop and .SelHeight are the key properties here.

Example with a subform.RecordsetClone loop:

Set F = Me.Subform.Form
Set RS = F.RecordsetClone
RS.MoveFirst
' goto first selected record
RS.Move F.SelTop - 1
' loop over all selected records
For i = 1 To F.SelHeight
    ' do something with fields from RS
    RS.MoveNext
Next i

Upvotes: 1

Related Questions