Dom wrote:
Salad <oi*@vinegar.com> wrote in message news:<vt*****************@newsread1.news.pas.earth link.net>...
Dom wrote:
Hi,
I have a werid problem with a subreport. If someone can help me out
I'd be very grateful!
Based on results from a query, the visibility of textboxes and labels
in a subreport are set to true or false. Some sample code is below. It
all looks straight foward however the desired output does not happen.
To makes things even more strange when I load the Print Preview of the
subreport and then switch to the Design View of the subreport and then
switch back to the Print Preview the correct information is shown. For
some reason it does not load correctly on the first time. Werid!
Has anyone any ideas?
Many Thanks,
Dom
Private Sub Report_Open(Cancel As Integer)
Dim strEmpty As String
strEmpty = ""
Dim strBreakdowns1 As String
strBreakdowns1 = Me.txtBreakdown1C.Value
If strBreakdowns1 = strEmpty Then
Me.txtBreakdown1C.Visible = False
Me.lblBreakdownsC.Visible = False
Else
Me.txtBreakdown1C.Visible = True
Me.lblBreakdownsC.Visible = True
End If
End Sub
What is the value of Me.txtBreakdown1C when you open a report? Is that
value on the detail line? You might want to place your code somewhere
else...like the detail band's OnFormat event. Do you want this to occur
on every line or for the entire report?
Here is something else I also do on statements line yours.
Me.txtBreakdown1C.Visible = (strBreakdowns1 = strEmpty)
Me.lblBreakdownsC.Visible = (strBreakdowns1 = strEmpty)
Hi Salad,
thanks very much for your reply! I like your neat tip on assigning
true/false to the control.....very nice!
As for my main problem I'm still stumped! The value of
Me.txtBreakdown1C will be either an empty string or some letter. When
its an empty string I want to hide it and when its a letter I show it.
The onformat event made no differance.
I want this formatting to occur for the whole report. There is only
one record displayed per page so if the next record is selected then
the formatting should occur again. There doesn't seem to be any events
to control this in reports. (the onChange event is for forms only)
The other thing I can't explain is why when I switch in and out and
the design view a couple of times the correct data eventually shows
up! I'm stumped!
Any further advice is much appreciated!
Thanks,
Dom
I created a junk report with 2 fields; ID and Code. I only want to
display the Code if the rightmost character is 0. So this is my code line
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Me.Code.Visible = (Right(Me.ID, 1) = 0)
End Sub
I will assume Me.txtBreakdown1C is a text field on your report and not
from the calling form. Every record where Me.txtBreakdown1C is empty
you don't want to display the label. You can select the label then cut
it. Then click on the associated field and paste it. Now the label and
textbox are associated. You only need to make invisible the textbox now.
Now, cut/paste this code into your report
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Me.txtBreakdown1C.Visible = (Me.txtBreakdown1C.Visible > "")
End Sub
This should work. Cut out any other previous attempts to make this
visible or invisible.