Manny has attended:
Access Intermediate course
Access Advanced course
Selecting a Fitlered Subform
Hi all,
I have a query on a form acting as a subform in a datasheet view.
I was the user to select the line items and move them to another table.
A user may use the filter option on the subform to help them with their choices on which line item they wish to move to another table.
How can i select the filtered items and move them?
Thanks, Manny
RE: Selecting a Fitlered Subform
Hi Manny,
Thank you for the forum question
Please have a look at the code below.
I haven't tested it but it should be a good help to point you in the right direction. The RecordsetClone should only store filtered records from the sub form.
Private Sub Command4_Click()
Dim rs1 As DAO.Recordset
Dim rs2 As DAO.Recordset
Set rs1 = Items_subform.Form.RecordsetClone
Set rs2 = dbs.OpenRecordset("Destination Table name", dbOpenTable)
With rs1
.MoveFirst
Do While Not .EOF
.rs2.AddNew
rs2!Field1 = !Field1
rs2!Field2 = !Field2
.......
.......
rs2.Update
.MoveNext
Loop
End With
rs1.Close
rs2.Close
Set rs1 = Nothing
Set rs2 = Nothing
End Sub
Kind regards
Jens Bonde
Microsoft Office Specialist Trainer
Tel: 0207 987 3777
STL - https://www.stl-training.co.uk
98%+ recommend us
London's leader with UK wide delivery in Microsoft Office training and management training to global brands, FTSE 100, SME's and the public sector
RE: Selecting a Fitlered Subform
Hi Jens,
I just ended up using the recordsetclone and it worked perfectly!
Thanks, Manny
RE: Selecting a Fitlered Subform
Well done Manny,
Stay safe and have a great day.
Kind regards
Jens Bonde
Microsoft Office Specialist Trainer
Tel: 0207 987 3777
STL - https://www.stl-training.co.uk
98%+ recommend us
London's leader with UK wide delivery in Microsoft Office training and management training to global brands, FTSE 100, SME's and the public sector