Why is a .Visible function changing values

chuckcoleman

Registered User.
Local time
Yesterday, 18:04
Joined
Aug 20, 2010
Messages
380
I'm going nuts! I have a sub report and based on data in the sub report, I want to make values either visible or not visible. In the Detail section of the sub report using the On Format property, I invoke the following code:

Code:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    If [Text29] = 0 And [Text37] <> 0 Then
        [BlockX].Visible = False
        LotDescXYZ.Visible = False
        RangeXYZ.Visible = False
        GraveDescX.Visible = False
        DescriptionX.Visible = False
        CalcAmtX.Visible = False
    ElseIf [Text29] = 0 And [Text37] = 0 Then
        [BlockX].Visible = True
        LotDescXYZ.Visible = True
        RangeXYZ.Visible = True
        GraveDescX.Visible = True
        DescriptionX.Visible = False
        CalcAmtX.Visible = False
    ElseIf [Text29] = 1 And [Text37] <> 0 Then
        [BlockX].Visible = True
        LotDescXYZ.Visible = True
        RangeXYZ.Visible = True
        GraveDescX.Visible = True
        DescriptionX.Visible = True
        CalcAmtX.Visible = True
    ElseIf [Text29] = 1 And [Text37] = 0 Then
        [BlockX].Visible = True
        LotDescXYZ.Visible = True
        RangeXYZ.Visible = True
        GraveDescX.Visible = True
        DescriptionX.Visible = True
        CalcAmtX.Visible = True
    End If
End Sub
What happens when the code runs is the value in [Text37] changes which makes no sense to me. If I remove the Event procedure, [Text37]'s value is correct. [Text29] and [Text37] are both in the sub report. I can't figure out why a "display" function, i.e. Control Name.Visible impacts the value in [Text37]. [Text37] is determined by a Running Sum on the text box to determine the number of records in the sub report.

Help!

Chuck
 
Last edited by a moderator:
When posting code (especially longer code) please use code tags.

codetag001.png
 
Ah, thanx Bob thats better

Chuck, which textbox is Text37 performing a running sum on? My only thought is, are you making that textbox invizible, thus causing Text37 to recalculate?
 
Just a thought, but what data types are attached to the textbox values? What I mean is, are they Integer, Long, Double, Currency, or a mix?
 
TheTerminator, they are all Fixed formatted text boxes. Frustrating!
 
TheTerminator, they are all Fixed formatted text boxes. Frustrating!

Yes, but that could be where your problem lies. Are the values of the fixed formatted text boxes based on double numbers? Are these values calculated. It could be a rounding problem, where the displayed value is 0.00 and you're happy that it has a value of zero and should, for example, be not visible, but the actual value of the unformatted data could be something like 0.000013 and therefore does not calculate to zero even though it displays as zero.

Just a thought that this could be what's baffling you. You could experiment with some sort of rounding function in the formula that sets the visible true/false property.
 

Users who are viewing this thread

Back
Top Bottom