Solved

Delete an empty page in Access Report using VBA

Posted on 2016-09-17
4
40 Views
Last Modified: 2016-09-23
I have a report template which has up to 5 pages per reservation (allows for up to 5 guests to register under one reservation). Now if I only have one or two guests in a singe reservation I need to suppress or delete the extra pages. Is there any easy way to delete the current page of a report using vba access? Thanks for any help. Rg Michael
0
Comment
Question by:mpim
  • 2
4 Comments
 
LVL 19
ID: 41803260
sounds like you have fields for each set of guests instead of making a related table.  If you do the latter, the report can print just what is there.
1
 

Author Comment

by:mpim
ID: 41803262
I agree a 100% but it is too cumbersome to change at this point in time.... Thanks Michael
0
 
LVL 19
ID: 41803265
it is actually a lot less cumbersome to change it than it is to be figuring out how to get around it ;) ~

all you need to do is make the table, put a foreign key in to the reservation (use AutoNumber in reservations and Long integer with no default value in related table) then make a form to be used as a subform on the reservation form (or whatever you call it), put ReservationID on it (can be hidden -- Visible=No), set LinkMasterFields and LinkChildFields for the subform (which you can drag from the navigation pane to the main form in design view) to be ReservationID , and let Access do its magic! Reporting is just as easy
0
 
LVL 57

Accepted Solution

by:
Jim Dettman (Microsoft MVP/ EE MVE) earned 500 total points
ID: 41803321
<<Is there any easy way to delete the current page of a report using vba access?>>

In short, no.   But you can set the section (assuming detail), CanShrink property to yes, and in the OnFormat event for the section, check each control:

 If NZ(Me.<somecontrol>,"") = ""  Then
     Me.<somecontrol>.Visible = False
 Else
     Me.<somecontrol>.Visible = True
 End if

 and repeat that for each control.   Assuming you have no grid lines or other controls, that should get rid of the blank pages.

Jim.
0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now