Solved

Not printing subreport based on a criteria

Posted on 2004-08-26
8
321 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
  • 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
 

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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
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.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

747 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

10 Experts available now in Live!

Get 1:1 Help Now