Hide a label on a report when printing (1 Viewer)

Falcon88

Registered User.
Local time
Today, 16:22
Joined
Nov 4, 2014
Messages
299
hii to all

on myForm there two buttons , one "A" for printing MyReport , "B" button for export that report "MyReport" to pdf format .

there a label on that report "MyReport" refer to the electronic version of that report "pdf version" like : this is an electronic version that didn't need to stamp .

my quesion : is there a way to hide that label when printing that report by myForm button "A" ?
 

Gasman

Enthusiastic Amateur
Local time
Today, 14:22
Joined
Sep 21, 2011
Messages
14,306
You could use OpenArgs?
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 08:22
Joined
Feb 28, 2001
Messages
27,186
OK, let's start with the fact that in a report, everything depends on a section and there are events related to each section. In the next link, scroll down to this: "Order of events for reports and report sections" then down to "Events for report sections."


Here's a tutorial about event sequences:


The idea is that you need to tell Access to suppress (or perhaps change) the message in a particular TextBox control which will appear in a particular section. That section might be the report header, might be the page header for a specific page, might be a group header. You will have to decide which one based on where this message is defined. In your specific case, I'm betting "report header."

When you open a report, there is an argument for the DoCmd.OpenReport action called "OpenArgs" - which is just a quoted string you can pass to the report. Depending on which button was used to launch the report, you can put different values into OpenArgs.

Inside the report, any section can look at Me.OpenArgs. At this point, all you need to do is to put code the correct section format event to test what, if anything, was passed in via the OpenArgs call argument and, based on the text, add, change, or remove the message in question before you exit that particular event.
 

CJ_London

Super Moderator
Staff member
Local time
Today, 14:22
Joined
Feb 19, 2013
Messages
16,614
surely you just need to change the displaywhen property of the label to screen only?

in your buttonA click event something like

mylabel.displaywhen=2 '1=print only, 2=screen only, 0=both
 

CJ_London

Super Moderator
Staff member
Local time
Today, 14:22
Joined
Feb 19, 2013
Messages
16,614
you have one in post #5 - and please do not use CAPITALS - it is considered RUDE
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 08:22
Joined
Feb 28, 2001
Messages
27,186
PLEASE GIVES ME AN EXAMPLE ...

We are an advice site primarily. We expect our members to take the advice so as to write their own code. We don't know your environment and have no reasonable way of knowing what would fit in with anything you actually have already. Therefore, we tend to explain how things are done. Some of us offer samples, but we do best when our members learn self-sufficiency.
 

Users who are viewing this thread

Top Bottom