I Dont Get It ? Positive Number Shows, Negative Number Does Not Show?

  • Thread starter Thread starter Dave Elliott
  • Start date Start date
D

Dave Elliott

This codes makes the Label423 show up, but if I change the >0 to <0 then the
Label does not show up, WHY?
The value in the textbox krap will be a negative number, i.e. -3 for the
criteria I want, ANY thing below zero
krap does not have a default format and it will always be a number.


Me.Label423.Visible = (Me.krap) >0 ' This Works Label
Shows
Me.Label423.Visible = (Me.krap) < 0 ' This Does Not Work Label Does Not
Show
 
This codes makes the Label423 show up, but if I change the >0 to <0 then the
Label does not show up, WHY?
The value in the textbox krap will be a negative number, i.e. -3 for the
criteria I want, ANY thing below zero
krap does not have a default format and it will always be a number.


Me.Label423.Visible = (Me.krap) >0 ' This Works Label
Shows
Me.Label423.Visible = (Me.krap) < 0 ' This Does Not Work Label Does Not
Show

If [krap] is on the same form as the code - i.e. if Label423 is on a
Subform, then krap should be on the same Subform - try

Me.Label423.Visible = (Val(Me.[krap]) < 0)

If the code is executing on a Subform, then, as suggested elsethread,
use Val(Parent![krap]) instead. Me means *the current form* - and if
you're on a subform, that means the Subform, not the parent form.

John W. Vinson[MVP]
 
None of these do the trick ???
Some make the Label423 visible , but never when krap is a negative number.

If Me.krap < 0 Then
Me.Label423.Visible = True
End If

If Nz(Me!krap, 0) < 0 Then
Me.Label423.Visible = True
Else:
Me.Label423.Visible = False
End If

Me.CI30.Visible = ([krap]) < 0

If Me.krap < 0 Then
Me.CI30.Visible = True
End If
CI30.Visible = (Me.krap) < 0

If (Val([krap]) > 0) Then
Label423.Visible = True
End If

John Vinson said:
This codes makes the Label423 show up, but if I change the >0 to <0 then
the
Label does not show up, WHY?
The value in the textbox krap will be a negative number, i.e. -3 for the
criteria I want, ANY thing below zero
krap does not have a default format and it will always be a number.


Me.Label423.Visible = (Me.krap) >0 ' This Works Label
Shows
Me.Label423.Visible = (Me.krap) < 0 ' This Does Not Work Label Does
Not
Show

If [krap] is on the same form as the code - i.e. if Label423 is on a
Subform, then krap should be on the same Subform - try

Me.Label423.Visible = (Val(Me.[krap]) < 0)

If the code is executing on a Subform, then, as suggested elsethread,
use Val(Parent![krap]) instead. Me means *the current form* - and if
you're on a subform, that means the Subform, not the parent form.

John W. Vinson[MVP]
 
It does not make the Label visible, just if you make it >

John Vinson said:
If (Val([krap]) > 0) Then
Label423.Visible = True
End If

How about changing the greater-than > to a less-than < in the above?

John W. Vinson[MVP]
 
John I got it... It is a timer problem, I had to invoke the Timer and set it
to 15
Thanks for your help.

John Vinson said:
If (Val([krap]) > 0) Then
Label423.Visible = True
End If

How about changing the greater-than > to a less-than < in the above?

John W. Vinson[MVP]
 
Ridiculous: I set the On Timer to to 15 and this code on the event
Result; The label does not show up period. Dont know what else to try!

If (Val([krap]) < 0) Then ' Timer Event
Label423.Visible = False
End If
Put this code on the On Current Event;
If (Val([krap]) >= 0) Then
Label423.Visible = False
End If

John Vinson said:
If (Val([krap]) > 0) Then
Label423.Visible = True
End If

How about changing the greater-than > to a less-than < in the above?

John W. Vinson[MVP]
 
Ridiculous: I set the On Timer to to 15 and this code on the event
Result; The label does not show up period. Dont know what else to try!

If (Val([krap]) < 0) Then ' Timer Event
Label423.Visible = False
End If
Put this code on the On Current Event;
If (Val([krap]) >= 0) Then
Label423.Visible = False
End If

Let's take one large step back. I think I jumped in in the middle of
this thread, and I may well be missing something.

The Timer event has ABSOLUTELY NOTHING to do with setting a control's
visibility (unless you want the control to be visible when the form is
opened and then have it disappear fifteen milliseconds later, which
would be more than a bit odd).

Please explain the following:

- What are you trying to accomplish? Why?
- What is on this Form? As you have been REPEATEDLY asked and have not
answered, is it a Form with a Subform, or more than one Subform? If
there is a subform, which form (main form or subform) is [krap] on?
which is [Label423] on? What event on the which form contains this
code?

John W. Vinson[MVP]
 
ALL Labels ARE ON THE MAIN FORM AND FIRE on the CURRENT EVENT
Note: some code WILL ONLY fire on the current event if there is a delay,
i.e. Timer Event
This comes form a lot of experience on my part, that is why I tried the code
this way!
I know this for a fact because of seeing it work and not work. Also some
code has to be moved up in the
order of code events to fire. Have been experimenting with these to no
success so far.
If the value of krap is below zero, then Label423 should be visible, else
not visible.


John Vinson said:
Ridiculous: I set the On Timer to to 15 and this code on the event
Result; The label does not show up period. Dont know what else to try!

If (Val([krap]) < 0) Then ' Timer Event
Label423.Visible = False
End If
Put this code on the On Current Event;
If (Val([krap]) >= 0) Then
Label423.Visible = False
End If

Let's take one large step back. I think I jumped in in the middle of
this thread, and I may well be missing something.

The Timer event has ABSOLUTELY NOTHING to do with setting a control's
visibility (unless you want the control to be visible when the form is
opened and then have it disappear fifteen milliseconds later, which
would be more than a bit odd).

Please explain the following:

- What are you trying to accomplish? Why?
- What is on this Form? As you have been REPEATEDLY asked and have not
(Main Form)
answered, is it a Form with a Subform, or more than one Subform? If
there is a subform, which form (main form or subform) is [krap] on?
which is [Label423] on? What event on the which form contains this
code?

John W. Vinson[MVP]
 
ALL Labels ARE ON THE MAIN FORM AND FIRE on the CURRENT EVENT
Thank you. That helps.
Note: some code WILL ONLY fire on the current event if there is a delay,
i.e. Timer Event
I have *NEVER* experienced this.
This comes form a lot of experience on my part, that is why I tried the code
this way!
I know this for a fact because of seeing it work and not work. Also some
code has to be moved up in the
order of code events to fire. Have been experimenting with these to no
success so far.
If the value of krap is below zero, then Label423 should be visible, else
not visible.

What is the Control Source of [krap]? What is the Recordsource of the
Form?

I would REALLY expect:

Private Sub Form_Current()
If Val(Me![krap]) < 0 Then
Me!Label423.Visible = True
Else
Me!Label423.Visible = False
End If
End Sub

or even

Me!Label423.Visible = (Me![krap] < 0)

to work perfectly, unless krap is being populated by some VBA code
operation that you haven't mentioned. If it's a bound field, bound to
a numeric table field, then I'm baffled as to why either of the above
should fail.

John W. Vinson[MVP]
 
krap gets it's control source from a sub-form, it just equals whatever is in
the field on the sub-form
=[FPaymentSub].[Form]![Balance] THIS is the control source for the
textbox krap
therefore eliminating referring to the sub-form altogether.
The format for both fields; krap and it's control source are currency
The MAIN form on the current event has a Call Function that uses a module.
Remember the MAIN has (5) sub-forms on it, but I am not using these for the
code now, except to refer to
a sub-form using a textbox with it's control source set to the textbox on
the sub-form.
I tried this code on a plain vanilla form and it works IF
you use -1 or whatever negative number (-2, or -3, etc...) for the value of
krap
<0 does not work.
Because the main form refreshes and calls a module and other (A Lot) of
code, it is sometimes necessary to use a timer event to make it all work.
What is funny is that I have some code which produces a similar result on
the sub-form that works,while the other codes does not.
If IsNull(Balance) Then
Label20.Visible = False
Else
Label20.Visible = (Balance < 0)
End If
Balance is the textbox on the sub-form that is being checked, i.e. krap='s
Balance


John Vinson said:
ALL Labels ARE ON THE MAIN FORM AND FIRE on the CURRENT EVENT
Thank you. That helps.
Note: some code WILL ONLY fire on the current event if there is a delay,
i.e. Timer Event
I have *NEVER* experienced this.
This comes form a lot of experience on my part, that is why I tried the
code
this way!
I know this for a fact because of seeing it work and not work. Also some
code has to be moved up in the
order of code events to fire. Have been experimenting with these to no
success so far.
If the value of krap is below zero, then Label423 should be visible, else
not visible.

What is the Control Source of [krap]? What is the Recordsource of the
Form?

I would REALLY expect:

Private Sub Form_Current()
If Val(Me![krap]) < 0 Then
Me!Label423.Visible = True
Else
Me!Label423.Visible = False
End If
End Sub

or even

Me!Label423.Visible = (Me![krap] < 0)

to work perfectly, unless krap is being populated by some VBA code
operation that you haven't mentioned. If it's a bound field, bound to
a numeric table field, then I'm baffled as to why either of the above
should fail.

John W. Vinson[MVP]
 
=[FPaymentSub].[Form]![Balance] THIS is the control source for the
textbox krap

Would there be any way to redo the subform's balance calculation in a
DSum() or other way of getting directly to the data in the table upon
which the subform is based?

I'm leaving for the weekend - back Monday - hope you get it resolved,
or that someone else jumps in!

John W. Vinson[MVP]
 
Just a suggestion, but if you press the F9 key for a recalc of the
controls or insert a repaint command.

=[FPaymentSub].[Form]![Balance] THIS is the control source for the
textbox krap

Would there be any way to redo the subform's balance calculation in a
DSum() or other way of getting directly to the data in the table upon
which the subform is based?

I'm leaving for the weekend - back Monday - hope you get it resolved,
or that someone else jumps in!

John W. Vinson[MVP]
 
Back
Top