AboutScottgem Expertise I can answer some questions on a wide variety of business applications, including MS Office, Lotus Smartsuite, Visio, Notes and many others.
Experience I have over 16 years of experience as an IT professional, supporting a wide variety of business applications.
Question In an Access 2007 database, is there a simple way in VBA to determine a (subform) datasheet's data (as filtered and ordered by the end user) in order to print just their selection via a print button on the main form?
Answer If there is a filter being applied to a subform, you can use the Filter property in the OpenReport method like so:
DoCmd.OpenReport "reportname",,,Me.Filter
However, this may not pick up the filtering that is performed by the parent-child link between the main form and subform so you may need to use:
DoCmd.OpenReport "reportname",,,Me.Filter & " AND [foreignkey] = " & Forms!mainformname!keycontrolname
Hope this helps,
Scott<>
Microsoft Access MVP 2007
Author: Microsoft Office Access 2007 VBA