Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
|
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 February 22nd, 2004, 01:14 AM
Registered User
 
Join Date: Feb 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Printing blank grid in detail section

Hi everyone,
One of my projects requires to print a list of student names for the teachers to take the attendance of a class. I have no problem generating the list of names. However, the problem is the teachers would like to have empty grids printed below the names in case some new students show up. The format should loop like this
------------------------------------------------------
Peter |Parker | [email protected]
------------------------------------------------------
Bruce |Wayne | [email protected]
------------------------------------------------------
       | |
------------------------------------------------------
       | |
-------------------------------------------------------

Please help! Thanx in advance.

Matt
 
Old February 22nd, 2004, 02:34 PM
Authorized User
 
Join Date: Feb 2004
Posts: 98
Thanks: 0
Thanked 0 Times in 0 Posts
Default

If one assumes that this 'print' isn't of an on screen form or to Excel or Word or some other program, then one might assume you are asking about a report, and in the Access world, these is bound to a recordset. Presumably you need a recordset that has a pair of empty rows at the bottom. Let's also assume that you need them sorted by last name. The ususal procedure is to use a Union of SQL clauses where you union a series of SELECT statments. The first SQL statement is, based on your example data with assumptions as to field and table names:

Select FirstName, LastName, Email From tblStudent Order By LastName, FirstName;

You could add a single empty record by adding a single union clause:

Select FirstName, LastName, Email From tblStudent Union Select '', '', '' From tblStudent Order By LastName, FirstName;

(those literals are pairs of apostrophes - single quotes - without anything between them) Unfortunately, the empty record will sort to the top. You can add up to 50 unioned Selects in Access 97 (I am not sure of more recent versions) and you have to specify Union All if you want identical '', '', '' records to appear for each one.

To attack the sort issue, you can select the last name and first name a second time and modify it in some way so that it still sorts the same yet is different from the field values. I like to prefix with a space: ' ' & FirstName As SortFirst for example. You may then specify a literal value which is likely to append the literal after conventional last and first names.

SELECT LastName, FirstName, Email, ' ' & LastName AS SortLast, ' ' & FirstName as SortFirst
FROM tblStudent Union Select '', '', '', 'ZZZ', 'ZZZ' From tblStudent Union Select '', '', '', 'ZZZz', 'ZZZz' From tblStudent
ORDER BY SortLast, SortFirst

Substitute your field and table names and leave out controls for displaying the SortLast and SortFirst fields in your report.

Ciao
Jurgen Welz
Edmonton AB Canada
[email protected]
 
Old February 22nd, 2004, 11:12 PM
Registered User
 
Join Date: Feb 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hey jurgenw,
It works fine, thanx for the tips!






Similar Threads
Thread Thread Starter Forum Replies Last Post
Shrink Detail section on a report TimLB Access 2 January 23rd, 2007 08:45 AM
How to fix the height of the detail section derekpuah Crystal Reports 0 May 11th, 2006 11:10 PM
Dynamic Detail section sudarshan73 Crystal Reports 1 January 20th, 2006 05:23 PM
how to increment in detail section cmdolcet Crystal Reports 0 July 12th, 2005 05:37 PM
Detail Section Height rickf Access VBA 1 January 29th, 2004 07:53 PM





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