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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Show or Hide Detail of Report 1

Status
Not open for further replies.

Zelandakh

MIS
Mar 12, 1999
12,173
GB
I have a tick box on a form called bTick on frmInput.

If the box is ticked, I want to show rptOutput.Detail and not show it if its not ticked.

I know I need to set the Visible property to No but can't see how to program it...the button that opens the report does the usual docmd.openreport preview so I guess its just before that.

Been scratching my head all morning on this...
 
Zelandakh, you will probably need a global variable and function to do this.
In a new module put something like this.

Public myFlag As Boolean

Public Function GetValue() As Boolean
GetValue = myFlag
End Function

Then in the click event for the button that opens the report put this

myFlag = Me.bTick
DoCmd.OpenReport "ReportName", acViewPreview

Then in the Report Open Event (you may need to change the event to something like the Format event for the Detail section) you would put

Private Sub Report_Open(Cancel As Integer)
If GetValue() = 0 Then
Me.Detail(0).Visible = False
Else
Me.Detail(0).Visible = True
End If
End Sub

I didn't run a test on the syntax for the Detail section so you may need to tweak that a little but this should be you real close.

Paul
 
Paul, I wouldn't have got close without that - apart from renaming detail(0) to detail, everything worked first time.

Very many thanks, and have a star on me.

I'm a very happy "developer".
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top