Solved

Not printing subreport based on a criteria

Posted on 2004-08-26
8
379 Views
Last Modified: 2008-03-10
i have a report containing subreports. is it possible NOT to print a subreport withhin a report based on a employee id#??

for ex, i dont want The project subreport to show up when im printing report for empid#100.? Pls advice.
0
Comment
Question by:thinker388
[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
  • 5
  • 3
8 Comments
 
LVL 41

Accepted Solution

by:
shanesuebsahakarn earned 500 total points
ID: 11907903
Yes it is. You can use the OnFormat event of the report section to do this. For example:

If Me!txtEmployeeID=100 Then
   Me!MySubReportControl.Visible=False
End If

txtEmployeeID in this case is the control that contains the EmployeeID (and I have assumed it is in the same section as the subreport). MySubReportControl is the name of the control that the subreport is contained in, not the subreport itself.

You may find it better to have a yes/no field in your table to determine if the subreport should be printed. You can then put this field into a hidden control and use say:
If Me!chkPrintSubreport=False Then
instead.

For best results, set the subreport to be of absolutely minimal height, and set the CanGrow property to yes.
0
 

Author Comment

by:thinker388
ID: 11907959
"If Me!txtEmployeeID=100 Then
   Me!MySubReportControl.Visible=False
End If"

well the empid doesnt get printed but its in the query on which the report is based.  so can i just reference the query?

"MySubReportControl is the name of the control that the subreport is contained in"...sorry i didnt get that...is the subreport contained within a control? r u talking abt the main report consisting of all the subreports?
0
 
LVL 41

Expert Comment

by:shanesuebsahakarn
ID: 11908001
Subreports and subforms live inside subreport and subform controls. Click on a subreport in design view. Bring up the Properties (View->Properties).

Look in the Other page at the Name property. This is the name of the control. Look in the Data page, at "Source Object". That is the name of the actual report inside the control. These two are often the same (especially if you create it automatically), but might not be.

As fpr the empid not being printed, just put it into a textbox on your report, and set the textbox's Visible property to No.
0
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 

Author Comment

by:thinker388
ID: 11908092
this is the code:

If [Forms]![frmReport]![txtemp] = "14564" Then
    Me![Project B-Jerry].Visible = False
End If

it errors out saying, access cant find the field Project B-Jerry referrred in my expression. I got the "Project B-Jerry " from Name property from the Other page. BTW my source object and the name property have diff values.
0
 
LVL 41

Expert Comment

by:shanesuebsahakarn
ID: 11908118
Whereabouts do you have the code running? Also, what is your SourceObject property (just to double check)?
0
 

Author Comment

by:thinker388
ID: 11908133
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

If [Forms]![frmReport]![txtemp] = "14564" Then
    Me![Project B-Jerry].Visible = False
End If

End Sub


sourceobject: Report.rptTasks
0
 

Author Comment

by:thinker388
ID: 11908143
oooh wait...got it..i was putting it on format event of the subreport not in the main report itself
0
 

Author Comment

by:thinker388
ID: 11908157
works a treat now..thanks much :)
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

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.
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

626 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