Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Suppress Detail Lines Conditionally 2

Status
Not open for further replies.

tammic

MIS
Apr 7, 2003
17
0
0
US
I have read many threads but have not yet found the answer, this should be easy!!!

I want to skip a detail line if the value of a field = 'Yes'. I have built an event procedure in the detail section (on format) as follows:

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Me.Late = "Yes" Then
Me.Detail.Visible = True
Else
Me.Detail.Visible = False
End If
End Sub

But it suppresses all of the detail, not just the line(s) that should be suppressed. I even tried the "cancel = true" option but that has the same results.

Anyone had any luck with this?

 
It's even simpler than that:

Code:
 Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
   If Me.Late = "Yes" Then Cancel= True 
End Sub

Simon Rouse
 
This code can hide the field if the text is yes, but can't suppress the empty area. Also it will take a long time to format. Better to control it in the query by writing <>Yes in the criteria of the query field.
Code:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Me.Late.Text = "Yes" Then
Me.Late.Visible = True
Else
Me.Late.Visible = False
End If
End Sub


Zameer Abdulla
Visit Me
Where to pay your [purple]Tsunami[/purple] relief donations?
 
I think not Zameer. If you look at tammic's original thread he says that he/she has tried "cancel=true".

tammic - reading your thread again you seem to have numerous controls in your detail section. I suspect that Zameer's suggestion of controlling the input data is the correct one.
Simon Rouse
 
Thanks for the responses, but when I used DrSimon's idea, the entire detail section suppressed. The lines that were suppose to print didn't.

Thank you also, ZmrAbdulla, but I can't limit the query because I need the underlying info in the report.

So neither of these will work for me...but thanks again!
 
What I meant was that the query could have an Iif statement like this:

IIf («Condition OK», «Normal Value», "")


Then the control would be empty. Assuming that it exists on its own line in the detail, set that control and Detail to 'Can Shrink' = Yes and it should work

Simon Rouse
 
DrSimon --

Your 1st approach did work after all. All along the Me.Late = "Yes" really should have been evaluated as Me.Late = True (or False). When I figured out I was using the wrong type and used the correct format, it worked like a charm.

Thank You!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top