Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

save filtered records on form.

Posted on 2013-01-24
3
Medium Priority
?
371 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 2000 total points
ID: 38813603
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
ID: 38813612
yes to save as you described
0
 

Author Closing Comment

by:PeterBaileyUk
ID: 38813705
thank you
0

Featured Post

Restore individual SQL databases with ease

Veeam Explorer for Microsoft SQL Server delivers an easy-to-use, wizard-driven interface for restoring your databases from a backup. No expert SQL background required. Web interface provides a complete view of all available SQL databases to simplify the recovery of lost database

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
Sometimes MS breaks things just for fun... In Access 2003, only the maximum allowable SQL string length could cause problems as you built a recordset. Now, when using string data in a WHERE clause, the 'identifier' maximum is 128 characters. So, …
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

804 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