Solved

save filtered records on form.

Posted on 2013-01-24
3
360 Views
Last Modified: 2013-01-24
I have a form and have filtered the records down, how can I save just the filtered records? the form is of continuous, i dont need to save every field though. am in access 2010 using vba
0
Comment
Question by:PeterBaileyUk
  • 2
3 Comments
 
LVL 61

Accepted Solution

by:
mbizup earned 500 total points
Comment Utility
Do you mean save them into a table other than what the form is bound to?

The subforms recordsetclone can be used for this - it contains the filtered records:

Dim rs as dao.recordset
Set rs = Forms!yourformname.recordsetclone

dim rsOut as dao.recordset '<--- this is the table where you are saving records to
set rsout = currentdb.openrecordset ("YourTable", dbopendynaset)

if rs.recordcount = 0 then 
      Msgbox "no records in form"
      exit sub
end if

do until rs.eof
      rsOut.edit  ' or addnew if you are creating new records
      rsOut!Field1 = rs!field1
      rsOut!Field2 = rs!field2
      rsout.update
      rs.MoveNext
Loop
set rs= nothing
rsout.close
set rsout = nothing

Open in new window

0
 

Author Comment

by:PeterBaileyUk
Comment Utility
yes to save as you described
0
 

Author Closing Comment

by:PeterBaileyUk
Comment Utility
thank you
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Join & Write a Comment

Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now