How make a control conditionally invisible?

L

LAS

The detail section of my report is a sub report. In that sub report is a
control that I want to be invisible if a certain control on the main report
is empty. I think the code below should work, but I can't figure out where
to put it. I've tried the sub report's detail Print event and Format event.
Nothing else looks like a candidate. Can someone help?

tia
las

If Nz([Reports]![rptStudentScoresDataSheet]![txtPersonalGoal], "") <> ""
Then
txtPrinciple5.Visible = True
Else
txtPrinciple5.Visible = False
End If
 
M

Marshall Barton

LAS said:
The detail section of my report is a sub report. In that sub report is a
control that I want to be invisible if a certain control on the main report
is empty. I think the code below should work, but I can't figure out where
to put it. I've tried the sub report's detail Print event and Format event.
Nothing else looks like a candidate. Can someone help?

If Nz([Reports]![rptStudentScoresDataSheet]![txtPersonalGoal], "") <> ""
Then
txtPrinciple5.Visible = True
Else
txtPrinciple5.Visible = False
End If

The subreport detail section's Format event is the right
place. txtPersonalGoal needs to be in the main report's
detail section or in a group header or the Report header.

BTW, that can be "simplified" to one line:

Me.txtPrinciple5.Visible = Nz(Parent!txtPersonalGoal,"")<>""
 
L

LAS

Thanks for reassuring me. Only an hour or so before I read your post I
discovered that Format events only trigger in print preview, not report
view. :)

Marshall Barton said:
LAS said:
The detail section of my report is a sub report. In that sub report is a
control that I want to be invisible if a certain control on the main
report
is empty. I think the code below should work, but I can't figure out
where
to put it. I've tried the sub report's detail Print event and Format
event.
Nothing else looks like a candidate. Can someone help?

If Nz([Reports]![rptStudentScoresDataSheet]![txtPersonalGoal], "") <>
""
Then
txtPrinciple5.Visible = True
Else
txtPrinciple5.Visible = False
End If

The subreport detail section's Format event is the right
place. txtPersonalGoal needs to be in the main report's
detail section or in a group header or the Report header.

BTW, that can be "simplified" to one line:

Me.txtPrinciple5.Visible = Nz(Parent!txtPersonalGoal,"")<>""
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top