Solved

Not printing subreport based on a criteria

Posted on 2004-08-26
8
369 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
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
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…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

734 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