gkadell
asked on
Set visibility of report label based on subreport value
I thought this would be very quick, but I can't get it right....I have a report "Forecast Accuracy Report Main" with a subreport "Forecast accuracy" (that's the name of the subreport control, the subreport itself if "Forecast Accuracy Subreport"). The subreport has a control called txtCount. I have labels on the main report and I want to set the visibility of these labels depending on the value in txtCount.
I was trying to put code in the OnOpen event of the main form:
If Me![Forecast accuracy].report.txtCount> 3 then
lblBias2.visible=true
if me![Forecast accuracy].report.txCount>6 then
lblBias3.visible=true
If me![Forecast accuracy].report.txtCount> 9 then
lblBias4.visible=true
end if
However, I can't get VBA to come up with lblBias2.visible, visible is not in the list of options that VBA gives me.
Also, am I correctly referencing txtCount?
Let me know if you need clarification.
Gladys
I was trying to put code in the OnOpen event of the main form:
If Me![Forecast accuracy].report.txtCount>
lblBias2.visible=true
if me![Forecast accuracy].report.txCount>6
lblBias3.visible=true
If me![Forecast accuracy].report.txtCount>
lblBias4.visible=true
end if
However, I can't get VBA to come up with lblBias2.visible, visible is not in the list of options that VBA gives me.
Also, am I correctly referencing txtCount?
Let me know if you need clarification.
Gladys
ASKER
I moved the code and am still having the problem. When I try to type "lblBias2.visible=true" the only options I have after "lblBias2." are Application, Column, Controls, DropDown, etc - and absolutely no option to set visible.
It needs to be:
Me!lblBias2.visible=true
Jim.
Me!lblBias2.visible=true
Jim.
It does not seem to matter whether you use "lblBias2", "Me.lblBias2" or "Me!lblBias2", the Auto List Memebers system will still not show "Visible" as a property of the label.
However, it IS a propery of a label, so just go ahead and type it manually and your code should work just fine. I tried it out in Access 97 with no trouble.
However, it IS a propery of a label, so just go ahead and type it manually and your code should work just fine. I tried it out in Access 97 with no trouble.
ASKER
Thanks for the suggestions, but neither Me!lblbias2.visible=true nor lblBias2.visible=true works. I changed the code to just test and see if I could affect visiblity and it does not work. Any other suggestions? I also am not certain whether or not I am referencing the control on the subform correctly.
<<Any other suggestions? >>
Are you sure the label is called 'lblBias2' (can be a little hard to see those lowercase L's at times)?
<<I also am not certain whether or not I am referencing the control on the subform correctly. >>
As long as '[Forecast accuracy]' is the name of the sub report *control* and not the name of the sub report, then yes, it's correct.
Jim.
Are you sure the label is called 'lblBias2' (can be a little hard to see those lowercase L's at times)?
<<I also am not certain whether or not I am referencing the control on the subform correctly. >>
As long as '[Forecast accuracy]' is the name of the sub report *control* and not the name of the sub report, then yes, it's correct.
Jim.
I concur with Jim. You need to use the name of the subreport control (as seen on the main report) not the name of the subreport itself - they can be different.
Also, have you tried the visibility part on it's own - without reference to the condition you want to test - just to see that the .Visible property setting does have an effect.
Finally, the code should be in the OnFormat event of the section that contains the label, not the section containing the report.
Also, have you tried the visibility part on it's own - without reference to the condition you want to test - just to see that the .Visible property setting does have an effect.
Finally, the code should be in the OnFormat event of the section that contains the label, not the section containing the report.
ASKER
<Am I sure the label is called 'lblBias2'>
I double-checked that (so many times I have been frustrated only to find that the control is not named what I thought it was), yes, I have the label names correct.
<have I tried the visibility part on its own?>
Yes, I am just testing the visibility part since that is what is giving me so much trouble. I am trying to set the visibility to false, and it does not work. It is frustrating, since I think that the code SHOULD work.
I do have it on the OnFormat of the section containing the label (both the label and subreport are in the same section). HELP!!!
I double-checked that (so many times I have been frustrated only to find that the control is not named what I thought it was), yes, I have the label names correct.
<have I tried the visibility part on its own?>
Yes, I am just testing the visibility part since that is what is giving me so much trouble. I am trying to set the visibility to false, and it does not work. It is frustrating, since I think that the code SHOULD work.
I do have it on the OnFormat of the section containing the label (both the label and subreport are in the same section). HELP!!!
ASKER
OK, I figured it out. I think this installation is buggy - it needs everything to be VERY specific. I wrote:
If Reports![Forecast Accuracy Report Main].Controls![Forecast Accuracy].Controls!txtCoun t > 6 Then
Reports![Forecast Accuracy Report Main].Controls!lblBias3.Vi sible = True
End If
and it works. Thanks for your comments.
If Reports![Forecast Accuracy Report Main].Controls![Forecast Accuracy].Controls!txtCoun
Reports![Forecast Accuracy Report Main].Controls!lblBias3.Vi
End If
and it works. Thanks for your comments.
ASKER
FYI - I have posted a question on Community Support asking them to close this question.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Cheers, Andrew