selecting fitlered subform

Forum home » Delegate support and help forum » Microsoft Access VBA Training and help » Selecting a Fitlered Subform

Selecting a Fitlered Subform

resolvedResolved · Urgent Priority · Version 2016

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

Thu 7 May 2020: Automatically marked as resolved.

 

Training courses

 

Training information:

Welcome. Please choose your application (eg. Excel) and then post your question.

Our Microsoft Qualified trainers will then respond within 24 hours (working days).

Frequently Asked Questions
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.


 

Access tip:

Creating Parameter wildcard queries

To creat a parameter query that also uses a wildcard, in the query design type in like []+*.

View all Access hints and tips


Server loaded in 0.11 secs.