Expressions on reports

L

LeLe

I am trying to get the following code to work,,, and it won't
The control headtop is bound to a numeric field with a single field size.
If the value is zero I want certain controls to appear on the form, and if
the value is greater than zero (>.01) I want a different set of controls to
appear.

Can anyone see what I am missing? I am using similar code in other parts of
the report and it works fine. I suspect something is wrong with the way I
have written the criteria, and it is not finding any records that match it.
Thanks so much!!

If Me.headtop > 0.01 Then
Me.headtop.Visible = True
Me.HeadTfig.Visible = True
Me.HeadTpic.Visible = True
Me.RetLtPrFig.Visible = False
Me.OverRtPrFig.Visible = False
Me.Return.Visible = False
Me.WidthFlatLab.Visible = True


Else
Me!headtop.Visible = False
Me.HeadTfig.Visible = False
Me.HeadTpic.Visible = False
Me.RetLtPrFig.Visible = True
Me.OverRtPrFig.Visible = True
Me.Return.Visible = True
Me.WidthFlatLab.Visible = False
 
F

fredg

I am trying to get the following code to work,,, and it won't
The control headtop is bound to a numeric field with a single field size.
If the value is zero I want certain controls to appear on the form, and if
the value is greater than zero (>.01) I want a different set of controls to
appear.

Can anyone see what I am missing? I am using similar code in other parts of
the report and it works fine. I suspect something is wrong with the way I
have written the criteria, and it is not finding any records that match it.
Thanks so much!!

If Me.headtop > 0.01 Then
Me.headtop.Visible = True
Me.HeadTfig.Visible = True
Me.HeadTpic.Visible = True
Me.RetLtPrFig.Visible = False
Me.OverRtPrFig.Visible = False
Me.Return.Visible = False
Me.WidthFlatLab.Visible = True


Else
Me!headtop.Visible = False
Me.HeadTfig.Visible = False
Me.HeadTpic.Visible = False
Me.RetLtPrFig.Visible = True
Me.OverRtPrFig.Visible = True
Me.Return.Visible = True
Me.WidthFlatLab.Visible = False

It's always best to copy and paste your actual code into a message.
The code you posted is missing (at the very least) an End If.
It may be that you just didn't include it in your message.
.01 is not the same as >0.
What if the actual value is .01? Or .001?
Each is larger than 0 but your code will not make those control's
visible or not visible because the value is not larger than .01.

Let's simplify your code, anyway.

Me.headtop.Visible = Me.Headtop >0
Me.HeadTfig.Visible = Me.Headtop >0
Me.HeadTpic.Visible = Me.Headtop >0
Me.RetLtPrFig.Visible = Not Me.Headtop >0
Me.OverRtPrFig.Visible = Not Me.Headtop >0
Me.Return.Visible = Not Me.Headtop >0
Me.WidthFlatLab.Visible = Me.Headtop >0
 
L

LeLe

Thanks so much for the suggested simplification.

I am not a programmer (if that wasn't already obvious). I just cut and
paste my way along, and with the help of this discussion group, have been
creating a pretty cool application for my company.

the .01 is ok since we make draperies and are happy if we get to the nearest
1/8 of an inch.

I believe I discovered my mistake when I looked at another peice of sample
code. My code contains 2 case statements and 3 if statements. For some reason
I had put all the end case and end ifs at the bottom of the code. The
debugger did not seem to mind so I didn't know better. When I moved them up
into the code, it now seems to be doing what I intended.

Thanks again for you help. I will implement your suggestion at
simplification.
 
Top