How to conditionally print subreports

Apschminkey

New member
Local time
Today, 11:47
Joined
Oct 6, 2006
Messages
2
I am making changes to a commercial laboratory LIMS system that our company uses to track and report test samples. We have a document called a “Lab Sheet” which is used to document various pieces of information before the data is entered into the computer. Currently, to print these lab sheets I have a form with a combo box from which the user can select an order number. An order is a collection of samples from single client. Each sample may have one or more tests assigned to it. The query which feeds the report takes the selected order number and finds all of the tests which are assigned to the samples in the order. A single Lab Sheet is printed for each test. The details section includes a list of test parameters associated with a particular test. People here are not happy with the simple list of test parameters and would like to design custom Lab Sheets for many of the tests. What I would like to do is create a single lab sheet having the normal headers/footers EXCEPT that the body of the report is produced by a subreport. All of the possible subreports for all of the possible tests would be placed on the main report. When test "X" comes up in the query, I would like to make visible ONLY the subreport corresponding to the lab sheet required for Test "X". If the next sheet to be printed is test "Z", I would like to print a sheet with only the test "Z" subreport. I found a piece of code (below) online which was written in response to a guy who was looking for a way to control the printing of a subreport.

--------------------------------------------------------
In the "On Page" event of the report, put the following code:

If YourFlag=True then
Me.subformname.Visible = False
Else
Me.subformname.Visible = True
End If

---------------------------------------------------------

Could I do something like:

If testName1=True then
Me.subformname.visible=true
If testname2=True then
Me.subformname.visible=true
If testname3=True then
Me.subformname.visible=true
If testname4=True then
Me.subformname.visible=true
Else
Me.DefaultSubform.visible=true
End if

The If/Else block is probably not correct (I struggle with that all the time) but I think you can see where I'm going with it. Am I on the right track?

Thanks!
 
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Me.Your_subreport.Visible = Me.Your_subreport.Report.HasData

End Sub
 
The data which is associated with each test is simply a list of the measurable parameters which are recorded when the test is performed. If I put TestName in the TestName header, the details section already gives me a list of these parameters. Instead of printing a single column list of details, I would essentially like to print a blank spreadsheet with blank rows and blank columns and whatever else the lab people want there. There is really no data involved here. It might be easier to think of in in this way: If Test "X" is called for, I want to print a PICTURE" of the test "X" lab form, not the actual data associated with text "X".
 

Users who are viewing this thread

Back
Top Bottom