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

Conditionally Suppress Subreport on Main Report 1

Status
Not open for further replies.

JOEYB99

Technical User
Jul 9, 2008
121
CA
I am using Access 2007.

I have a simple subreport that appears - as intended - beside a subtotal amount in a main report.

I want to suppress/hide this subreport when the subtotal amount is greater than $1,000. How can I do this?

I'm fairly new to VBA code and event procedures.

Any help would be greatly appreciated.
 
You should be able to use vba code in the On Format event of the main report section containing the subtotal and subreport. The code might look like:

Code:
[pre]
    [COLOR=#4E9A06]'the names below are your control names[/color]
    Me.subreportname.visible = Me.txtSubTotalControlName < 1000
[/pre]

Duane
Hook'D on Access
MS Access MVP
 
Thanks dhookom.

In Design View I went to the Group Footer section where the subtotal amount and the subreport appear. I then entered your vba code under the On Format property, for that section. I substituted in the proper control names in your code.

When I clicked to preview my report I received an error message stating "Compile error: Method or data member not found." It then high-lighted the control name of the subreport just after the 'Me.' in your code.

Am I missing something in my syntax?

I am not that strong on VBA. Any help would be greatly appreciated.
 


Here is the code,

Private Sub GroupFooter1_Format(Cancel As Integer, FormatCount As Integer)

Me.rptTotalOutstandingApprovalsBySubjob.Visible = Me.[AccessTotalsAmount 1] < 1000

End Sub



What is the difference between the subreport control name and the source object?

I did compile of this code, and I did not receive any error messages.


 
A subreport on a main report has both a name property and a source object property. Many times, these are the same. Your code needs to reference the name property.

Duane
Hook'D on Access
MS Access MVP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top