Hide report elements conditionally (1 Viewer)

jeffreyccs

New member
Local time
Yesterday, 20:42
Joined
Nov 10, 2012
Messages
29
Hi


I have a report that contains six fields, with the first being the question number, the next four containing data and the final field containing a number between 1 and 4, this being the criteria to hide one of the four data fields.


The report is for administering a test where there are three out of four variables given and the student must derive the fourth. I would prefer to be able to print both answer sheet and test from one report, but am struggling to find a way to do it.



If anyone could point me in the right direction any advice would be gratefully received.
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 20:42
Joined
Oct 29, 2018
Messages
21,455
Hi. One possible approach is to use a query for your report where all four fields are calculated based on the last one. For example:
Code:
=IIf([Field6]=2,"",[Field2]
This would hide the second field if Field6=2. Hope it helps...
 

MajP

You've got your good things, and you've got mine.
Local time
Yesterday, 23:42
Joined
May 21, 2018
Messages
8,525
I interpreted a little differently. That you want to tell the report to show or hide depending on if it is an answer or test sheet. So I prompt in the onopen event.

Code:
Private Sub Report_Open(Cancel As Integer)
  If InputBox("Hide?", "Show Hide", "No") = "Yes" Then Me.TotalSessions.Visible = False
End Sub

Is it one field that gets hidden or is the field random?
 

jeffreyccs

New member
Local time
Yesterday, 20:42
Joined
Nov 10, 2012
Messages
29
Hi


Thanks for the replies which I will try out.


In the meantime I have amended my code to provide an alternative. As the test was generated in an array with the final column being the pointer to the field to be hidden, prior to posting the data to the table I moved the 'answer' value to the last array value and then posted the table.


This allows the printing of the report without answers, with the answer column easily shown when required.


Many thanks for your advice


Regards


Jeff
 

MajP

You've got your good things, and you've got mine.
Local time
Yesterday, 23:42
Joined
May 21, 2018
Messages
8,525
As the test was generated in an array with the final column being the pointer to the field to be hidden,

This still would be possible, but you would have to use the onpaint event of the detail section. Each record gets "painted" in order. So on that event you determine what to show and hide. So you could hide different fields.
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 20:42
Joined
Oct 29, 2018
Messages
21,455
Hi Jeff. Good luck with your project.
 

Users who are viewing this thread

Top Bottom