Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA 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 May 4th, 2009, 01:16 AM
Authorized User
 
Join Date: Feb 2005
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Cool Last Record in a Report

Hello,

Anyone knows a way to find out when Access prints the last record in a report? There is a thing I want to do for each record (in the Detail section) but not when the last report in printed. Not the Page footer or the Report footer I am talking about the last record in the acDetail section.

I do program some reports occasionally and it is easy to find out in a form but in a report I am stuck. Thanks.
__________________
Daniel
 
Old May 6th, 2009, 04:53 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

Place a hidden textbox in the detail section. Call it, say, txtItemNo. In its control source, place the formula

=1

In its properties, set Running Sum = Over All.

In the detail section's On Format Event place this IF statement.

Code:
If Me.txtItemNo = DCount("[Primary Key Here]", "Report's Record Source Here") Then
    'Last Record.  Do this.
Else
    'Not the last record.  Do that.
End If
Replace "Primary Key Here" and "Report's Record Source Here" with their actual values. Also replace my comments with actual code.
__________________
Greg Serrano
Michigan Dept. of Environmental Quality
Air Quality Division
 
Old May 7th, 2009, 08:56 AM
Authorized User
 
Join Date: Feb 2005
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Default Last Record in a Report

Thanks SerranoG

Yep that would do the job all right. Thanks a bunch that is very clever.

Appreciated.
__________________
Daniel





Similar Threads
Thread Thread Starter Forum Replies Last Post
One Record Printing TWICE on Report. PaulJH Access VBA 4 February 15th, 2008 09:33 AM
Colouring first record of report [Solved] Svenzardda Access VBA 1 July 18th, 2007 06:44 AM
Report Displays Only One Record dlandolin Access 1 June 6th, 2007 12:18 PM
Record number in Access Report Niaz Access 4 July 19th, 2005 01:48 PM
First and Last Record in Report Header cc16 Access VBA 7 September 10th, 2004 09:37 AM





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