Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old August 27th, 2003, 08:55 PM
Registered User
Join Date: Aug 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Help required Selective Printing Access Reports

I am developing an Access97 database (Win NT4 environment). I would like to incorporate a button in a form which will enable selected records to be printed from an associated report. Currently I have set up Print and Preview buttons, but the Print button, prints out every record instead of selected ones.

Can anybody assist with this task, as I am a relatively new Access user.

Jim Bendfeldt
Old August 27th, 2003, 10:13 PM
Friend of Wrox
Join Date: Jun 2003
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts

Hi Jim,

Need a little more info.

How are you selecting the records you need printed (i.e., what controls are you using)? What field values are you using as your selection criteria? Are you selecting a single criteria or multiple criteria? Is the record source for your report a saved query, or are you building your SQL dynamically? Have you set parameters in a query that reference controls on the form, or are you using the reports filter property, or the WhereCondition argument of DoCmd.OpenReport? There's lots of ways to filter a report's record source. What does your data look like?

Using the WhereCondition approach is pretty straight forward. The bare-bones of it are something like this:

First, base your report on a query that contains the field(s) you are using as a criteria value to select records. Then,

Private Sub cmdPrint_Click()

    Dim strCriteria As String

    ' Pull your report criteria from a control on the form
    strCriteria = "[MyField] = " & Me.cboMyComboBox
    DoCmd.OpenReport "MyReport", acNormal, , strCriteria

End Sub

You don't have to set any parameters in the query itself using this approach, though that's another way to go.

What's your setup look like so far? Post a little VBA and/or SQL if you can.



Old August 27th, 2003, 10:27 PM
Friend of Wrox
Join Date: Jun 2003
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts

Hi Jim,

While I'm thinking about it, also download Microsoft's Access 97 Sample Reports Database at KB article 175072:


Wealth of report filtering techniques demostrated.



Similar Threads
Thread Thread Starter Forum Replies Last Post
printing reports ivnurse2001 VB How-To 2 May 20th, 2007 12:07 AM
Printing Reports From Forms Brendan Bartley Access 1 June 30th, 2006 07:35 AM
printing and alignment in reports collie BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 1 April 14th, 2005 08:09 AM
capturing printing settings when printing reports nikolaosk Access VBA 0 February 8th, 2005 04:14 AM
Printing reports tucker Access VBA 1 February 9th, 2004 01:04 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.