Hide certain fields if checkmark is unchecked

buratti

Registered User.
Local time
Today, 12:37
Joined
Jul 8, 2009
Messages
234
I'm trying to create a report base on a form that amongst other data, has 4 check boxes and each has a few associated fields. If all of those associated fields are blank, then obviously the checkbox would be blank.
In my report, based on that form, I want to hide the checkbox and its associated fields and labels if that checkbox is blank.
The report is formatted like so... Line 1 - customer data, Line 2 - checkbox 1 and associated data, Line 3 - check box 2 and associated data, Line 4 - checkbox 3 and associated data, and so on till the last check box, then the next record and repeat. I put the following code in the load event of the report:
Private Sub Report_Load()
If Me.PayforYear = False Then
Me.PayforYear.Visible = False
Me.PFYLabel.Visible = False
Me.PFYAMTLabel.Visible = False
Me.PFY_Amount.Visible = False
Me.PFY_Startdate.Visible = False
Me.PFY_Enddate.Visible = False
Me.PFYStartLabel.Visible = False
Me.PFYEndLabel.Visible = False
End If
If Me.Past_Due = False Then
Me.Past_Due.Visible = False
Me.PastDueLabel.Visible = False
Me.PastDueAmtLabel.Visible = False
Me.Past_Due_Amount.Visible = False
Me.Past_Due_paidtill_Date.Visible = False
Me.PayTillLabel.Visible = False
End If
If Me.Standard_Payment = False Then
Me.Standard_Amount.Visible = False
Me.StandardLabel.Visible = False
Me.Standard_Payment.Visible = False
Me.StandardAmtLabel.Visible = False
End If
If Me.Recurring = False Then
Me.Recurring.Visible = False
Me.RecurringLabel.Visible = False
Me.Reoccurring_Amount.Visible = False
Me.RecurringAmtLabel.Visible = False
Me.Reoccurring_Startdate.Visible = False
Me.RecurringStartLabel.Visible = False
End If

This works, but not consistently. Meaning all the records are based on what checkmarks are checked in the first record. Ex. If record 1 has checkmark 1 checked only, it will hide all that are unchecked, but also keep those same ones hidden in the rest of the records regardless if they are checked or not in those records. What is wrong with this and how can I fix it to display only the checked checkboxes for EACH record in the report?
 
buratti,

You definitely don't want to put all of that code in the Report's OnLoad event.
The report's DetailFormat event would be more appropriate.

You shouldn't really have to put any code at all. Investigate using Conditional
Formatting.

Search here and within Access Help.

That should be what you need.

Wayne
 
Thanks for the reply. I messed around with conditional formatting a little, but couldn't get anything to work. Can you control labels with conditional formatting? I couldn't find any way to do so. I also moved my code to on format event of the detail section and it did absolutely nothing.
Let me rephrase my question a bit here. If my fields are null then they will essentially be blank on the report so no need to hide them, BUT my labels for those fields are positioned right next to them and not in the header. Basically I need to hide the labels if that checkbox is unchecked. I don’t care much about having a blank line in the report, but if you can move data up to remove a blank line then that would be great also.
 
Wait a minute. does the on format event of the detail only work in the print prieview view of the report? I was testing all along in the regular report view and it was doing nothing, but in print prieview I got some results, but still not EXACTLY what I was looking for. With my original code above, an example is...
2 records are displaying in the report. Record 1, paid for year checkmark is checked, record 2 it is not. my code "hides" the paid for year checkmark and related fields for both/all records in the report. Basically, if any one of the checkmarks are unchecked, it hides it in all records, and not just the unchecked record.
 

Users who are viewing this thread

Back
Top Bottom