By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,363 Members | 3,622 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,363 IT Pros & Developers. It's quick & easy.

Selecting only one page out of a several-page report for printing - how to route in Access?

P: n/a
I hope someone will tell me how to do this without having to do any VB
as I know nothing in that area. I am a rank beginner in using Access.

I have created a database consisting of student athletes. *I have now
learned how to join two different tables in a query so that I might
generate a report.

Specifically, student athletes at a community college are required to
graduate with an AA or AS degree. *Consequently, various steps are in
place to ensure they are in compliance. *In this database, one
specific table is dedicated to their following the steps necessary. *

The report generated from this query is several hundred pages long.
*Other than slowly going through each page of the report to find a
specific student and then only printing that one page (by using cntl-p
and then selecting the specific page for that specific student), how
can I selectively print one page only through a query / report format?
*

If that is not possible, what can I do without having to modify code
anyplace? *

TIA.

Nov 13 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
You can do this manually by using the Student's unique identifier, probably
a student id code, as criteria for the query, so as to print the report only
for a single student. With minimal VBA code, you can create the
WhereCondition argument for a DoCmd.OpenReport statement to allow the user
to choose the student from a form and report just the one student.

Larry Linson
Microsoft Access MVP

<Sami> wrote in message news:rs********************************@4ax.com...
I hope someone will tell me how to do this without having to do any VB
as I know nothing in that area. I am a rank beginner in using Access.

I have created a database consisting of student athletes. I have now
learned how to join two different tables in a query so that I might
generate a report.

Specifically, student athletes at a community college are required to
graduate with an AA or AS degree. Consequently, various steps are in
place to ensure they are in compliance. In this database, one
specific table is dedicated to their following the steps necessary.

The report generated from this query is several hundred pages long.
Other than slowly going through each page of the report to find a
specific student and then only printing that one page (by using cntl-p
and then selecting the specific page for that specific student), how
can I selectively print one page only through a query / report format?
If that is not possible, what can I do without having to modify code
anyplace?

TIA.

Nov 13 '05 #2

P: n/a
Hi Sami,

I can think of a couple of approaches just off the top of my head -- that
should be possible to make using wizards, mostly.

Method #1.) -- Not neccesarily the best choice, but it is the easiest ...
IMHO.
----------------------------------------------------------------------------
--
a.) Create a form based on the same query as the report, so that the desired
students are included in the forms recordset.
b.) Create a combo-box in the form's header section using a similarly
filtered query that will be used to find the desired student. (Use the "Find
a record on my form" option in the combo-box wizard)
c.) Create a command button that prints just the current record. ("Record
operations" / "Print Record")
d.) The button wizard will generate code that looks like this, which should
work "as-is":
******************************************
Private Sub Command1_Click()
On Error GoTo Err_Command1_Click
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70 ' This selects
the current record.
'There is a better way to select the current record, but I won't get
into that just now. :-)

DoCmd.PrintOut acSelection ' This prints out the selected record

Exit_Command1_Click:
Exit Sub

Err_Command1_Click:
MsgBox Err.Description
Resume Exit_Command14_Click

End Sub
******************************************

Method #2) -- Involves a little more work, and possibly a lot of confusion
for a newbie... so I'll try to explain it fairly thoroughly. I do think
you'd be most happy with the results produced using this method.
----------------------------------------------------------------------------
--
a & b) as above
c.) Create another form (temorarily) that is also based on a table which
includes the students. This does not need to be filtered by acheivement, but
it has to have the "StudentID" (if that's what youhave named it) For the
sake of this example, close and save this form as "frmStudentTEMP"
d.) Create a command button that opens "frmStudentTEMP" and displays the
same record. (My intent here is to create, then modify the code generated by
the wizard so that it opens your existing report instead of the temporary
form.)
e.) Use "Form Operations" / "Open Form" [Next]
Select "frmStudentTEMP" from the list. [Next]
"Open the form and find specific data to display" {Next]
Select "StudentID" as the field from both list-boxes, and click the
"[<->]" button, then [Next]
Follow the prompts and make choices as you like, then click [Finish] at
the end.

f.) The wizard-generated code should look something like this:
******************************************
Private Sub Command2_Click()
On Error GoTo Err_Command2_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmStudentTEMP"

stLinkCriteria = "[StudentID]=" & Me![StudentID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command2_Click:
Exit Sub

Err_Command2_Click:
MsgBox Err.Description
Resume Exit_Command2_Click

End Sub
******************************************
All that remains to do now is to edit the generated code ...
Change the "stDocName = " statement, replacing "frmStudentTEMP" with the
name of your report.
You'll also have to change "DoCmd.OpenForm" to "DoCmd.OpenReport"
You may also want to edit this to add the "acViewPreview" paramaeter,
inserting it between the first and second commas.
You could go ahead and delete the temporary form at this point, as long as
the report opens correctly.
Then I think you're "good to go"!

*********************( revised code example )*********************
Private Sub Command2_Click()
On Error GoTo Err_Command2_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "YourReportNameHere" '<<<----- You'll need to change this!

stLinkCriteria = "[StudentID]=" & Me![StudentID]
DoCmd.OpenReport stDocName, acViewPreview, , stLinkCriteria '<<<----
I changed "OpenForm" to "OpenReport"
'and added the "acViewPreview" parameter for you here

Exit_Command2_Click:
Exit Sub

Err_Command2_Click:
MsgBox Err.Description
Resume Exit_Command2_Click

End Sub
******************************************

--
HTH,
Don
=============================
Use My*****@Telus.Net for e-mail
Disclaimer:
Professional PartsPerson
Amateur Database Programmer {:o)

I'm an Access97 user, so all posted code
samples are also Access97- based
unless otherwise noted.

Do Until SinksIn = True
File/Save, <slam fingers in desk drawer>
Loop

================================

<Sami> wrote in message news:rs********************************@4ax.com...
I hope someone will tell me how to do this without having to do any VB
as I know nothing in that area. I am a rank beginner in using Access.

I have created a database consisting of student athletes. I have now
learned how to join two different tables in a query so that I might
generate a report.

Specifically, student athletes at a community college are required to
graduate with an AA or AS degree. Consequently, various steps are in
place to ensure they are in compliance. In this database, one
specific table is dedicated to their following the steps necessary.

The report generated from this query is several hundred pages long.
Other than slowly going through each page of the report to find a
specific student and then only printing that one page (by using cntl-p
and then selecting the specific page for that specific student), how
can I selectively print one page only through a query / report format?
If that is not possible, what can I do without having to modify code
anyplace?

TIA.

Nov 13 '05 #3

P: n/a
This sounds easy enough. How and where (very specifically how and
where!) would I do it?

On Mon, 21 Jun 2004 02:10:43 GMT, "Larry Linson"
<bo*****@localhost.not> wrote:
You can do this manually by using the Student's unique identifier, probably
a student id code, as criteria for the query, so as to print the report only
for a single student. With minimal VBA code, you can create the
WhereCondition argument for a DoCmd.OpenReport statement to allow the user
to choose the student from a form and report just the one student.

Larry Linson
Microsoft Access MVP

<Sami> wrote in message news:rs********************************@4ax.com...
I hope someone will tell me how to do this without having to do any VB
as I know nothing in that area. I am a rank beginner in using Access.

I have created a database consisting of student athletes. I have now
learned how to join two different tables in a query so that I might
generate a report.

Specifically, student athletes at a community college are required to
graduate with an AA or AS degree. Consequently, various steps are in
place to ensure they are in compliance. In this database, one
specific table is dedicated to their following the steps necessary.

The report generated from this query is several hundred pages long.
Other than slowly going through each page of the report to find a
specific student and then only printing that one page (by using cntl-p
and then selecting the specific page for that specific student), how
can I selectively print one page only through a query / report format?
If that is not possible, what can I do without having to modify code
anyplace?

TIA.


Nov 13 '05 #4

P: n/a

Wait wait wait wait wait wait......

If not already the case, base you report on a query rather than directly
on a table. Then, in the query designer enter a criteria for the
Student ID. Criteria is entered on the forth ROW down of the StudentID
column. Have a look you'll see what I mean.

In this cell of the grid enter this:

=[Enter a Student ID]

Then when you run the report, you will be asked (strangely) to 'Enter a
Student ID', type in the Student ID you wish to report on and that
student should then be the only one displayed.

You can get trickier if you like and open the report from a button on a
form STILL without entering any VB code.

If you care to know more just reply and ask.
Cheers
Mr. Smith.
Sami wrote:
This sounds easy enough. How and where (very specifically how and
where!) would I do it?

On Mon, 21 Jun 2004 02:10:43 GMT, "Larry Linson"
<bo*****@localhost.not> wrote:

You can do this manually by using the Student's unique identifier, probably
a student id code, as criteria for the query, so as to print the report only
for a single student. With minimal VBA code, you can create the
WhereCondition argument for a DoCmd.OpenReport statement to allow the user
to choose the student from a form and report just the one student.

Larry Linson
Microsoft Access MVP

<Sami> wrote in message news:rs********************************@4ax.com...
I hope someone will tell me how to do this without having to do any VB
as I know nothing in that area. I am a rank beginner in using Access.

I have created a database consisting of student athletes. I have now
learned how to join two different tables in a query so that I might
generate a report.

Specifically, student athletes at a community college are required to
graduate with an AA or AS degree. Consequently, various steps are in
place to ensure they are in compliance. In this database, one
specific table is dedicated to their following the steps necessary.

The report generated from this query is several hundred pages long.
Other than slowly going through each page of the report to find a
specific student and then only printing that one page (by using cntl-p
and then selecting the specific page for that specific student), how
can I selectively print one page only through a query / report format?
If that is not possible, what can I do without having to modify code
anyplace?

TIA.

Nov 13 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.