Solved

Delete an empty page in Access Report using VBA

Posted on 2016-09-17
4
63 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 20
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 20
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…

739 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