Visible or Invisible Code

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

Dave Elliott

This code should make a (NUMBER) field visible or invisible but does not,
why?
The number field is Text21, it is a sub-form on a main form named
frmAutoPayrollReport.
The code below is on current from form frmAutoPayrollReport

If Nz(Me.FTimeBillingSub.Form!Text21) < 31 Then
Me.Text335.Visible = True
Else
Me.Text335.Visible = False
End If
 
Not sure what you want to happen. This code is run when the OnCurrent event
of the main form occurs? Does the subform "move" with the change in main
form's record? It's possible that the subform's control does not have a
"new" value yet when the main form record changes (assuming that the subform
is linked to the main form), though the use of Nz function should ensure a
zero value being returned if a Null is encountered. The subform control may
still have the previous record's value.

Have you stepped through the code to be sure that the value of
Me.FTimeBillingSub.Form!Text21 is what you expect it to be?
 
Basically the field on the sub-form (FTimeBillingSub) which is linked to the
main form frmAutoPayrollReport requeries itself after a value changes.
The field Tex21 which is unbound shows how many days have passed since the
Invoice was made. It is a number field.
Then the field on the form frmAutoPayrollReport Text335 should be visible if
the value of Text21 is less than 31, otherwise it should be invisible.
 
I'm guessing that the code is not running when you think it's supposed to be
running. Try putting a breakpoint on the
If Nz(Me.FTimeBillingSub.Form!Text21) < 31 Then
line and see if the code actually runs when you expect it to.

Likely you'll need to put this code on a different event, but I am not sure
which one to recommend yet based on what you've posted. I am not sure which
"value" is changing and therefore what should trigger the code to run.
 
Text335 value is currency if this makes a difference
Also I tried putting a Text Box on the main form TimeCards named Text355
which value is linked to Text box on sub-from FTimeBillingSub Text Box 21
Then I put this code on the before update event for the main form TimeCards
and it still did not work.

If Nz(Me.Text355) < 31 Then

Me.Text335.Visible = True

Else
Me.Text335.Visible = False
End If
 
There is a module associated with this form, maybe this is the problem.
I took out all other code and added code to module.
Function EnableCtl() 'Error-handler inserted on 12/30/2003 at 18:38 by Dave
Elliott
On Error GoTo EnableCtl_Error 'This is to use on the TimeCards form only.

If IsNull(Forms!Timecards!TimeID) Or IsNull(Forms!Timecards!StartDte) Then
Forms!Timecards!FTimeBillingSub.Visible = False
Forms!Timecards!FPaymentSub.Visible = False
Forms!Timecards!LblPrtQuot.Visible = True
Else:
Forms!Timecards!FTimeBillingSub.Visible = True
Forms!Timecards!FPaymentSub.Visible = True
Forms!Timecards!LblPrtQuot.Visible = False
End If
If Forms!Timecards!Text355 < 31 Then

Forms!Timecards!Text335.Visible = True
Else
Forms!Timecards!Text335.Visible = False
End If

EnableCtl_Exit:
Exit Function
EnableCtl_Error:
MsgBox "Unexpected error - " & Err.Number & vbCrLf & vbCrLf & Error$,
vbExclamation, "WithHoldTax - EnaCtl ModDate"
Resume EnableCtl_Exit
End Function
 
Ok, got it kinda. the problem is that Text335 equals a value and it still
show a value even if it is $0.00
Is there a way to make it be invisible even if the value is 0 as well as
If Text355 <31 Then
Text335.Visible = True
Else
Text335.Visible = False
End If

Below is the Value of the field, it is a calculated field.

=[BidA]*0.02
 
Try this:

If Text355 > 0 And Text355 < 31 Then
Text335.Visible = True
Else
Text335.Visible = False
End If

--

Ken Snell
<MS ACCESS MVP>

Dave Elliott said:
Ok, got it kinda. the problem is that Text335 equals a value and it still
show a value even if it is $0.00
Is there a way to make it be invisible even if the value is 0 as well as
If Text355 <31 Then
Text335.Visible = True
Else
Text335.Visible = False
End If

Below is the Value of the field, it is a calculated field.

=[BidA]*0.02

Dave Elliott said:
Tried that, didn't work

Text
Box change
in that
the invisible
but
 
Still didn't work, it is visible even if Text355 is greater than 30.
Should default value of Text335 be set to visible or not, does this make a
difference? Under it's properties I mean.


Ken Snell said:
Try this:

If Text355 > 0 And Text355 < 31 Then
Text335.Visible = True
Else
Text335.Visible = False
End If

--

Ken Snell
<MS ACCESS MVP>

Dave Elliott said:
Ok, got it kinda. the problem is that Text335 equals a value and it still
show a value even if it is $0.00
Is there a way to make it be invisible even if the value is 0 as well as
If Text355 <31 Then
Text335.Visible = True
Else
Text335.Visible = False
End If

Below is the Value of the field, it is a calculated field.

=[BidA]*0.02

Dave Elliott said:
Tried that, didn't work

Try putting the code on the OnCurrent event of the main form.

--

Ken Snell
<MS ACCESS MVP>

Text335 value is currency if this makes a difference
Also I tried putting a Text Box on the main form TimeCards named
Text355
which value is linked to Text box on sub-from FTimeBillingSub Text
Box
21
Then I put this code on the before update event for the main form
TimeCards
and it still did not work.

If Nz(Me.Text355) < 31 Then

Me.Text335.Visible = True

Else
Me.Text335.Visible = False
End If





I'm guessing that the code is not running when you think it's supposed
to
be
running. Try putting a breakpoint on the
If Nz(Me.FTimeBillingSub.Form!Text21) < 31 Then
line and see if the code actually runs when you expect it to.

Likely you'll need to put this code on a different event, but I
am
not
sure
which one to recommend yet based on what you've posted. I am not sure
which
"value" is changing and therefore what should trigger the code
to
run.
--

Ken Snell
<MS ACCESS MVP>

Basically the field on the sub-form (FTimeBillingSub) which is
linked
to
the
main form frmAutoPayrollReport requeries itself after a value
changes.
The field Tex21 which is unbound shows how many days have passed
since
the
Invoice was made. It is a number field.
Then the field on the form frmAutoPayrollReport Text335 should be
visible
if
the value of Text21 is less than 31, otherwise it should be
invisible.




Not sure what you want to happen. This code is run when the
OnCurrent
event
of the main form occurs? Does the subform "move" with the change
in
main
form's record? It's possible that the subform's control does not
have
a
"new" value yet when the main form record changes (assuming that
the
subform
is linked to the main form), though the use of Nz function should
ensure
a
zero value being returned if a Null is encountered. The subform
control
may
still have the previous record's value.

Have you stepped through the code to be sure that the value of
Me.FTimeBillingSub.Form!Text21 is what you expect it to be?


--

Ken Snell
<MS ACCESS MVP>

This code should make a (NUMBER) field visible or invisible
but
does
not,
why?
The number field is Text21, it is a sub-form on a main form
named
frmAutoPayrollReport.
The code below is on current from form
frmAutoPayrollReport

If Nz(Me.FTimeBillingSub.Form!Text21) < 31 Then
Me.Text335.Visible = True
Else
Me.Text335.Visible = False
End If
 
What is the format of Text355 control? Is it a text-formatted control? Or a
numeric-formatted control? You said that it's unbound, and has an expression
for the control source.

I note that you're testing the value of Text355 in order to set the visible
property of Text335? Is this correct? You don't mean to test Text355 and set
the visible property of Text355?

Did you try putting a breakpoint on the code so that it stops on the If ..
then statement? When it does, put cursor over the Text355 word and see what
value it has ... is it the value that you expect?

I'm not sure what you mean by the other post where you say Text355 is (can
be?) a negative number? Are you saying that the test for zero should look at
it being not exactly zero instead of greater than zero? Or did you mean that
you want to see if Text355 is less than 31 and Text335 is not equal to zero?

You earlier said that the value of *the* "field" is
=[BidA]*0.02
Which control (not field) has this as its control source?

I'm afraid that my confusion is growing and I need some clarification,
please. Thanks.
--

Ken Snell
<MS ACCESS MVP>



Dave Elliott said:
Still didn't work, it is visible even if Text355 is greater than 30.
Should default value of Text335 be set to visible or not, does this make a
difference? Under it's properties I mean.


Ken Snell said:
Try this:

If Text355 > 0 And Text355 < 31 Then
Text335.Visible = True
Else
Text335.Visible = False
End If

--

Ken Snell
<MS ACCESS MVP>

Dave Elliott said:
Ok, got it kinda. the problem is that Text335 equals a value and it still
show a value even if it is $0.00
Is there a way to make it be invisible even if the value is 0 as well as
If Text355 <31 Then
Text335.Visible = True
Else
Text335.Visible = False
End If

Below is the Value of the field, it is a calculated field.

=[BidA]*0.02

Tried that, didn't work

Try putting the code on the OnCurrent event of the main form.

--

Ken Snell
<MS ACCESS MVP>

Text335 value is currency if this makes a difference
Also I tried putting a Text Box on the main form TimeCards named
Text355
which value is linked to Text box on sub-from FTimeBillingSub Text
Box
21
Then I put this code on the before update event for the main form
TimeCards
and it still did not work.

If Nz(Me.Text355) < 31 Then

Me.Text335.Visible = True

Else
Me.Text335.Visible = False
End If





I'm guessing that the code is not running when you think it's
supposed
to
be
running. Try putting a breakpoint on the
If Nz(Me.FTimeBillingSub.Form!Text21) < 31 Then
line and see if the code actually runs when you expect it to.

Likely you'll need to put this code on a different event, but
I
am should
be does
not (assuming
that
value
 
SEE BELOW: FOR YOUR REPLY:



Ken Snell said:
What is the format of Text355 control? (FORMAT NOT SET) (ALTHOUGH IT WILL
BE A NUMBER) Is it a text-formatted control? Or a
numeric-formatted control? You said that it's unbound, and has an expression
for the control source. (YES =[FTimeBillingSub].[Form]![Text21] IS ITS CONTROL SOURCE )

I note that you're testing the value of Text355 in order to set the visible
property of Text335? Is this correct? (YES) You don't mean to test Text355 and set
the visible property of Text355? (NO)

Did you try putting a breakpoint on the code so that it stops on the If ..
then statement? (YES) When it does, put cursor over the Text355 word and see what
value it has ... is it the value that you expect?

I'm not sure what you mean by the other post where you say Text355 is (can
be?) a negative number? (THE NUMBER IN IT SAYS -30 instead of 30 ) Are
you saying that the test for zero should look at
it being not exactly zero instead of greater than zero? Or did you mean that
you want to see if Text355 is less than 31 and Text335 is not equal to zero?

You earlier said that the value of *the* "field" is
=[BidA]*0.02 (TEXT335 CONTROL SOURCE IS [Bid]*0.02 )
Which control (not field) has this as its control source? (TEXT335)

I'm afraid that my confusion is growing and I need some clarification,
please. Thanks.
--

Ken Snell
<MS ACCESS MVP>



Dave Elliott said:
Still didn't work, it is visible even if Text355 is greater than 30.
Should default value of Text335 be set to visible or not, does this make a
difference? Under it's properties I mean.
well
as
If Text355 <31 Then
Text335.Visible = True
Else
Text335.Visible = False
End If

Below is the Value of the field, it is a calculated field.

=[BidA]*0.02

Tried that, didn't work

Try putting the code on the OnCurrent event of the main form.

--

Ken Snell
<MS ACCESS MVP>

Text335 value is currency if this makes a difference
Also I tried putting a Text Box on the main form TimeCards named
Text355
which value is linked to Text box on sub-from FTimeBillingSub
Text
Box
21
Then I put this code on the before update event for the main form
TimeCards
and it still did not work.

If Nz(Me.Text355) < 31 Then

Me.Text335.Visible = True

Else
Me.Text335.Visible = False
End If





I'm guessing that the code is not running when you think it's
supposed
to
be
running. Try putting a breakpoint on the
If Nz(Me.FTimeBillingSub.Form!Text21) < 31 Then
line and see if the code actually runs when you expect it to.

Likely you'll need to put this code on a different event,
but
I code
to
which
function
 
You said that you did put a breakpoint on the code so that it stops on the
If ..then statement. When it does stop on that line, put cursor over the
Text355 word and see what value it has ... is it the value that you expect?
This is important for troubleshooting.


Based on the fact that the value can be negative, this may be better for
your code:

If Text355 <> 0 And Abs(Text355) < 31 Then
Text335.Visible = True
Else
Text335.Visible = False
End If


Also, just in case Text355 is coming as a text string (don't know why it
should, but just in case):

If Val(Text355) <> 0 And Abs(Val(Text355)) < 31 Then
Text335.Visible = True
Else
Text335.Visible = False
End If

--

Ken Snell
<MS ACCESS MVP>

Dave Elliott said:
SEE BELOW: FOR YOUR REPLY:



Ken Snell said:
What is the format of Text355 control? (FORMAT NOT SET) (ALTHOUGH IT
WILL
BE A NUMBER) Is it a text-formatted control? Or a
numeric-formatted control? You said that it's unbound, and has an expression
for the control source. (YES =[FTimeBillingSub].[Form]![Text21] IS ITS CONTROL SOURCE )

I note that you're testing the value of Text355 in order to set the visible
property of Text335? Is this correct? (YES) You don't mean to test Text355 and set
the visible property of Text355? (NO)

Did you try putting a breakpoint on the code so that it stops on the If ...
then statement? (YES) When it does, put cursor over the Text355 word and see what
value it has ... is it the value that you expect?

I'm not sure what you mean by the other post where you say Text355 is (can
be?) a negative number? (THE NUMBER IN IT SAYS -30 instead of 30 ) Are
you saying that the test for zero should look at
it being not exactly zero instead of greater than zero? Or did you mean that
you want to see if Text355 is less than 31 and Text335 is not equal to zero?

You earlier said that the value of *the* "field" is
=[BidA]*0.02 (TEXT335 CONTROL SOURCE IS [Bid]*0.02 )
Which control (not field) has this as its control source? (TEXT335)

I'm afraid that my confusion is growing and I need some clarification,
please. Thanks.
--

Ken Snell
<MS ACCESS MVP>



Dave Elliott said:
Still didn't work, it is visible even if Text355 is greater than 30.
Should default value of Text335 be set to visible or not, does this
make
a
difference? Under it's properties I mean.


Try this:

If Text355 > 0 And Text355 < 31 Then
Text335.Visible = True
Else
Text335.Visible = False
End If

--

Ken Snell
<MS ACCESS MVP>

Ok, got it kinda. the problem is that Text335 equals a value and it
still
show a value even if it is $0.00
Is there a way to make it be invisible even if the value is 0 as
well
as
If Text355 <31 Then
Text335.Visible = True
Else
Text335.Visible = False
End If

Below is the Value of the field, it is a calculated field.

=[BidA]*0.02

Tried that, didn't work

Try putting the code on the OnCurrent event of the main form.

--

Ken Snell
<MS ACCESS MVP>

Text335 value is currency if this makes a difference
Also I tried putting a Text Box on the main form TimeCards
named
Text355
which value is linked to Text box on sub-from FTimeBillingSub
Text
Box
21
Then I put this code on the before update event for the main form
TimeCards
and it still did not work.

If Nz(Me.Text355) < 31 Then

Me.Text335.Visible = True

Else
Me.Text335.Visible = False
End If





I'm guessing that the code is not running when you think it's
supposed
to
be
running. Try putting a breakpoint on the
If Nz(Me.FTimeBillingSub.Form!Text21) < 31 Then
line and see if the code actually runs when you expect it to.

Likely you'll need to put this code on a different event,
but
I
am
not
sure
which one to recommend yet based on what you've posted. I
am
not
sure
which
"value" is changing and therefore what should trigger the code
to
run.

--

Ken Snell
<MS ACCESS MVP>

Basically the field on the sub-form (FTimeBillingSub)
which
is
linked
to
the
main form frmAutoPayrollReport requeries itself after a value
changes.
The field Tex21 which is unbound shows how many days have
passed
since
the
Invoice was made. It is a number field.
Then the field on the form frmAutoPayrollReport Text335 should
be
visible
if
the value of Text21 is less than 31, otherwise it should be
invisible.




message
Not sure what you want to happen. This code is run
when
the
OnCurrent
event
of the main form occurs? Does the subform "move" with the
change
in
main
form's record? It's possible that the subform's
control
does
not
have
a
"new" value yet when the main form record changes (assuming
that
the
subform
is linked to the main form), though the use of Nz
function
should
ensure
a
zero value being returned if a Null is encountered. The
subform
control
may
still have the previous record's value.

Have you stepped through the code to be sure that the value
of
Me.FTimeBillingSub.Form!Text21 is what you expect it
to
be?
--

Ken Snell
<MS ACCESS MVP>

message
This code should make a (NUMBER) field visible or
invisible
but
does
not,
why?
The number field is Text21, it is a sub-form on a main
form
named
frmAutoPayrollReport.
The code below is on current from form
frmAutoPayrollReport

If Nz(Me.FTimeBillingSub.Form!Text21) < 31 Then
Me.Text335.Visible = True
Else
Me.Text335.Visible = False
End If
 
Ok, Ken, 0 to 30 days code works, just not next code: (Text338) & 9Text340)


If Text355 <> 0 And Abs(Text355) < 31 Then
Text335.Visible = True
Else
Text335.Visible = False
End If
If Text355 > 30 And Abs(Text355) < 61 Then
Text338.Visible = True
Else
Text338.Visible = False
End If
If Text355 > 60 And Abs(Text355) < 180 Then
Text340.Visible = True
Else
Text340.Visible = False
End If

















Ken Snell said:
You said that you did put a breakpoint on the code so that it stops on the
If ..then statement. When it does stop on that line, put cursor over the
Text355 word and see what value it has ... is it the value that you expect?
This is important for troubleshooting.


Based on the fact that the value can be negative, this may be better for
your code:

If Text355 <> 0 And Abs(Text355) < 31 Then
Text335.Visible = True
Else
Text335.Visible = False
End If


Also, just in case Text355 is coming as a text string (don't know why it
should, but just in case):

If Val(Text355) <> 0 And Abs(Val(Text355)) < 31 Then
Text335.Visible = True
Else
Text335.Visible = False
End If

--

Ken Snell
<MS ACCESS MVP>

Dave Elliott said:
SEE BELOW: FOR YOUR REPLY:



Ken Snell said:
What is the format of Text355 control? (FORMAT NOT SET) (ALTHOUGH IT
WILL
BE A NUMBER) Is it a text-formatted control? Or a
numeric-formatted control? You said that it's unbound, and has an expression
for the control source. (YES =[FTimeBillingSub].[Form]![Text21]
IS
ITS CONTROL SOURCE )
I note that you're testing the value of Text355 in order to set the visible
property of Text335? Is this correct? (YES) You don't mean to test Text355 and set
the visible property of Text355? (NO)

Did you try putting a breakpoint on the code so that it stops on the
If
..
then statement? (YES) When it does, put cursor over the Text355
word
and see what
value it has ... is it the value that you expect?

I'm not sure what you mean by the other post where you say Text355 is (can
be?) a negative number? (THE NUMBER IN IT SAYS -30 instead of 30 )
Are
you saying that the test for zero should look at
it being not exactly zero instead of greater than zero? Or did you
mean
that
you want to see if Text355 is less than 31 and Text335 is not equal to zero?

You earlier said that the value of *the* "field" is
=[BidA]*0.02 (TEXT335 CONTROL SOURCE IS [Bid]*0.02 )
Which control (not field) has this as its control source? (TEXT335)

I'm afraid that my confusion is growing and I need some clarification,
please. Thanks.
--

Ken Snell
<MS ACCESS MVP>



Still didn't work, it is visible even if Text355 is greater than 30.
Should default value of Text335 be set to visible or not, does this
make
a
difference? Under it's properties I mean.


Try this:

If Text355 > 0 And Text355 < 31 Then
Text335.Visible = True
Else
Text335.Visible = False
End If

--

Ken Snell
<MS ACCESS MVP>

Ok, got it kinda. the problem is that Text335 equals a value
and
it
still
show a value even if it is $0.00
Is there a way to make it be invisible even if the value is 0 as well
as
If Text355 <31 Then
Text335.Visible = True
Else
Text335.Visible = False
End If

Below is the Value of the field, it is a calculated field.

=[BidA]*0.02

Tried that, didn't work

Try putting the code on the OnCurrent event of the main form.

--

Ken Snell
<MS ACCESS MVP>

Text335 value is currency if this makes a difference
Also I tried putting a Text Box on the main form TimeCards
named
Text355
which value is linked to Text box on sub-from FTimeBillingSub
Text
Box
21
Then I put this code on the before update event for the main
form
TimeCards
and it still did not work.

If Nz(Me.Text355) < 31 Then

Me.Text335.Visible = True

Else
Me.Text335.Visible = False
End If





I'm guessing that the code is not running when you think it's
supposed
to
be
running. Try putting a breakpoint on the
If Nz(Me.FTimeBillingSub.Form!Text21) < 31 Then
line and see if the code actually runs when you expect
it
to.
Likely you'll need to put this code on a different
event,
but
I
am
not
sure
which one to recommend yet based on what you've posted.
I
am the
code should
be with
the
 
Assuming that the "negative" value possibility applies to all:

If Text355 <> 0 And Abs(Text355) < 31 Then
Text335.Visible = True
Else
Text335.Visible = False
End If
If Text355 > 30 And Abs(Text355) < 61 Then
Text338.Visible = True
Else
Text338.Visible = False
End If
If Text355 > 60 And Abs(Text355) < 180 Then
Text340.Visible = True
Else
Text340.Visible = False
End If

However, let me suggest a tidier code to use instead of the above:
Dim lngValue As Long
lngValue = Abs(Text355)
Text335.Visible = (lngValue < 31 And lngValue <> 0)
Text338.Visible = (lngValue > 30 And lngValue < 61)
Text340.Visible = (lngValue > 60 And lngValue < 180)

--

Ken Snell
<MS ACCESS MVP>



Dave Elliott said:
Ok, Ken, 0 to 30 days code works, just not next code: (Text338) & 9Text340)


If Text355 <> 0 And Abs(Text355) < 31 Then
Text335.Visible = True
Else
Text335.Visible = False
End If
If Text355 > 30 And Abs(Text355) < 61 Then
Text338.Visible = True
Else
Text338.Visible = False
End If
If Text355 > 60 And Abs(Text355) < 180 Then
Text340.Visible = True
Else
Text340.Visible = False
End If

















Ken Snell said:
You said that you did put a breakpoint on the code so that it stops on the
If ..then statement. When it does stop on that line, put cursor over the
Text355 word and see what value it has ... is it the value that you expect?
This is important for troubleshooting.


Based on the fact that the value can be negative, this may be better for
your code:

If Text355 <> 0 And Abs(Text355) < 31 Then
Text335.Visible = True
Else
Text335.Visible = False
End If


Also, just in case Text355 is coming as a text string (don't know why it
should, but just in case):

If Val(Text355) <> 0 And Abs(Val(Text355)) < 31 Then
Text335.Visible = True
Else
Text335.Visible = False
End If

--

Ken Snell
<MS ACCESS MVP>

Dave Elliott said:
SEE BELOW: FOR YOUR REPLY:



What is the format of Text355 control? (FORMAT NOT SET) (ALTHOUGH IT WILL
BE A NUMBER) Is it a text-formatted control? Or a
numeric-formatted control? You said that it's unbound, and has an
expression
for the control source. (YES =[FTimeBillingSub].[Form]![Text21] IS
ITS CONTROL SOURCE )

I note that you're testing the value of Text355 in order to set the
visible
property of Text335? Is this correct? (YES) You don't mean to test
Text355 and set
the visible property of Text355? (NO)

Did you try putting a breakpoint on the code so that it stops on the
If
..
then statement? (YES) When it does, put cursor over the Text355 word
and see what
value it has ... is it the value that you expect?

I'm not sure what you mean by the other post where you say Text355
is
(can
be?) a negative number? (THE NUMBER IN IT SAYS -30 instead of 30 ) Are
you saying that the test for zero should look at
it being not exactly zero instead of greater than zero? Or did you mean
that
you want to see if Text355 is less than 31 and Text335 is not equal to
zero?

You earlier said that the value of *the* "field" is
=[BidA]*0.02 (TEXT335 CONTROL SOURCE IS [Bid]*0.02 )
Which control (not field) has this as its control source? (TEXT335)

I'm afraid that my confusion is growing and I need some clarification,
please. Thanks.
--

Ken Snell
<MS ACCESS MVP>



Still didn't work, it is visible even if Text355 is greater
than
30.
Should default value of Text335 be set to visible or not, does
this
make
a
difference? Under it's properties I mean.


Try this:

If Text355 > 0 And Text355 < 31 Then
Text335.Visible = True
Else
Text335.Visible = False
End If

--

Ken Snell
<MS ACCESS MVP>

Ok, got it kinda. the problem is that Text335 equals a value
and
it
still
show a value even if it is $0.00
Is there a way to make it be invisible even if the value is 0 as
well
as
If Text355 <31 Then
Text335.Visible = True
Else
Text335.Visible = False
End If

Below is the Value of the field, it is a calculated field.

=[BidA]*0.02

Tried that, didn't work

Try putting the code on the OnCurrent event of the main form.

--

Ken Snell
<MS ACCESS MVP>

Text335 value is currency if this makes a difference
Also I tried putting a Text Box on the main form TimeCards
named
Text355
which value is linked to Text box on sub-from FTimeBillingSub
Text
Box
21
Then I put this code on the before update event for the main
form
TimeCards
and it still did not work.

If Nz(Me.Text355) < 31 Then

Me.Text335.Visible = True

Else
Me.Text335.Visible = False
End If





message
I'm guessing that the code is not running when you think
it's
supposed
to
be
running. Try putting a breakpoint on the
If Nz(Me.FTimeBillingSub.Form!Text21) < 31 Then
line and see if the code actually runs when you expect it
to.

Likely you'll need to put this code on a different event,
but
I
am
not
sure
which one to recommend yet based on what you've
posted.
after
a
value
changes.
The field Tex21 which is unbound shows how many days have
passed
since
the
Invoice was made. It is a number field.
Then the field on the form frmAutoPayrollReport Text335
should
be
visible
if
the value of Text21 is less than 31, otherwise it should
be
invisible.




message
Not sure what you want to happen. This code is run when
the
OnCurrent
event
of the main form occurs? Does the subform "move" with
the
change
in
main
form's record? It's possible that the subform's control
does
not
have
a
"new" value yet when the main form record changes
(assuming
that
the
subform
is linked to the main form), though the use of Nz
function

should
ensure
a
zero value being returned if a Null is
encountered.
The
subform
control
may
still have the previous record's value.

Have you stepped through the code to be sure that the
value
of
Me.FTimeBillingSub.Form!Text21 is what you expect
it
to
 
Hip, Hip, Hooray,, Thanks, that works really well. Thanks for your help and
patience.
Dave

Ken Snell said:
Assuming that the "negative" value possibility applies to all:

If Text355 <> 0 And Abs(Text355) < 31 Then
Text335.Visible = True
Else
Text335.Visible = False
End If
If Text355 > 30 And Abs(Text355) < 61 Then
Text338.Visible = True
Else
Text338.Visible = False
End If
If Text355 > 60 And Abs(Text355) < 180 Then
Text340.Visible = True
Else
Text340.Visible = False
End If

However, let me suggest a tidier code to use instead of the above:
Dim lngValue As Long
lngValue = Abs(Text355)
Text335.Visible = (lngValue < 31 And lngValue <> 0)
Text338.Visible = (lngValue > 30 And lngValue < 61)
Text340.Visible = (lngValue > 60 And lngValue < 180)

--

Ken Snell
<MS ACCESS MVP>



Dave Elliott said:
Ok, Ken, 0 to 30 days code works, just not next code: (Text338) & 9Text340)


If Text355 <> 0 And Abs(Text355) < 31 Then
Text335.Visible = True
Else
Text335.Visible = False
End If
If Text355 > 30 And Abs(Text355) < 61 Then
Text338.Visible = True
Else
Text338.Visible = False
End If
If Text355 > 60 And Abs(Text355) < 180 Then
Text340.Visible = True
Else
Text340.Visible = False
End If

















Ken Snell said:
You said that you did put a breakpoint on the code so that it stops on the
If ..then statement. When it does stop on that line, put cursor over the
Text355 word and see what value it has ... is it the value that you expect?
This is important for troubleshooting.


Based on the fact that the value can be negative, this may be better for
your code:

If Text355 <> 0 And Abs(Text355) < 31 Then
Text335.Visible = True
Else
Text335.Visible = False
End If


Also, just in case Text355 is coming as a text string (don't know why it
should, but just in case):

If Val(Text355) <> 0 And Abs(Val(Text355)) < 31 Then
Text335.Visible = True
Else
Text335.Visible = False
End If

--

Ken Snell
<MS ACCESS MVP>

SEE BELOW: FOR YOUR REPLY:



What is the format of Text355 control? (FORMAT NOT SET) (ALTHOUGH IT
WILL
BE A NUMBER) Is it a text-formatted control? Or a
numeric-formatted control? You said that it's unbound, and has an
expression
for the control source. (YES =[FTimeBillingSub].[Form]![Text21] IS
ITS CONTROL SOURCE )

I note that you're testing the value of Text355 in order to set the
visible
property of Text335? Is this correct? (YES) You don't mean to test
Text355 and set
the visible property of Text355? (NO)

Did you try putting a breakpoint on the code so that it stops on
the
If
..
then statement? (YES) When it does, put cursor over the Text355 word
and see what
value it has ... is it the value that you expect?

I'm not sure what you mean by the other post where you say Text355 is
(can
be?) a negative number? (THE NUMBER IN IT SAYS -30 instead of
30 )
Are
you saying that the test for zero should look at
it being not exactly zero instead of greater than zero? Or did you mean
that
you want to see if Text355 is less than 31 and Text335 is not
equal
to
zero?

You earlier said that the value of *the* "field" is
=[BidA]*0.02 (TEXT335 CONTROL SOURCE IS [Bid]*0.02 )
Which control (not field) has this as its control source? (TEXT335)

I'm afraid that my confusion is growing and I need some clarification,
please. Thanks.
--

Ken Snell
<MS ACCESS MVP>



Still didn't work, it is visible even if Text355 is greater than
30.
Should default value of Text335 be set to visible or not, does this
make
a
difference? Under it's properties I mean.


Try this:

If Text355 > 0 And Text355 < 31 Then
Text335.Visible = True
Else
Text335.Visible = False
End If

--

Ken Snell
<MS ACCESS MVP>

Ok, got it kinda. the problem is that Text335 equals a
value
and
it
still
show a value even if it is $0.00
Is there a way to make it be invisible even if the value is
0
as
well
as
If Text355 <31 Then
Text335.Visible = True
Else
Text335.Visible = False
End If

Below is the Value of the field, it is a calculated field.

=[BidA]*0.02

Tried that, didn't work

Try putting the code on the OnCurrent event of the main form.

--

Ken Snell
<MS ACCESS MVP>

Text335 value is currency if this makes a difference
Also I tried putting a Text Box on the main form TimeCards
named
Text355
which value is linked to Text box on sub-from
FTimeBillingSub
Text
Box
21
Then I put this code on the before update event for
the
main
form
TimeCards
and it still did not work.

If Nz(Me.Text355) < 31 Then

Me.Text335.Visible = True

Else
Me.Text335.Visible = False
End If





message
I'm guessing that the code is not running when you think
it's
supposed
to
be
running. Try putting a breakpoint on the
If Nz(Me.FTimeBillingSub.Form!Text21) < 31 Then
line and see if the code actually runs when you
expect
it
to.

Likely you'll need to put this code on a different event,
but
I
am
not
sure
which one to recommend yet based on what you've
posted.
I
am
not
sure
which
"value" is changing and therefore what should
trigger
the
code
to
run.

--

Ken Snell
<MS ACCESS MVP>

message
Basically the field on the sub-form (FTimeBillingSub)
which
is
linked
to
the
main form frmAutoPayrollReport requeries itself
after
a
value
changes.
The field Tex21 which is unbound shows how many days
have
passed
since
the
Invoice was made. It is a number field.
Then the field on the form frmAutoPayrollReport Text335
should
be
visible
if
the value of Text21 is less than 31, otherwise it should
be
invisible.




"Ken Snell" <[email protected]>
wrote
in
message
Not sure what you want to happen. This code is run
when
the
OnCurrent
event
of the main form occurs? Does the subform "move" with
the
change
in
main
form's record? It's possible that the subform's
control
does
not
have
a
"new" value yet when the main form record changes
(assuming
that
the
subform
is linked to the main form), though the use of Nz
function

should
ensure
a
zero value being returned if a Null is encountered.
The
subform
control
may
still have the previous record's value.

Have you stepped through the code to be sure
that
the
value
of
Me.FTimeBillingSub.Form!Text21 is what you
expect
 
You're welcome.

--

Ken Snell
<MS ACCESS MVP>

Dave Elliott said:
Hip, Hip, Hooray,, Thanks, that works really well. Thanks for your help and
patience.
Dave

Ken Snell said:
Assuming that the "negative" value possibility applies to all:

If Text355 <> 0 And Abs(Text355) < 31 Then
Text335.Visible = True
Else
Text335.Visible = False
End If
If Text355 > 30 And Abs(Text355) < 61 Then
Text338.Visible = True
Else
Text338.Visible = False
End If
If Text355 > 60 And Abs(Text355) < 180 Then
Text340.Visible = True
Else
Text340.Visible = False
End If

However, let me suggest a tidier code to use instead of the above:
Dim lngValue As Long
lngValue = Abs(Text355)
Text335.Visible = (lngValue < 31 And lngValue <> 0)
Text338.Visible = (lngValue > 30 And lngValue < 61)
Text340.Visible = (lngValue > 60 And lngValue < 180)

--

Ken Snell
<MS ACCESS MVP>



on
the
why
(ALTHOUGH
IT
WILL
BE A NUMBER) Is it a text-formatted control? Or a
numeric-formatted control? You said that it's unbound, and has an
expression
for the control source. (YES =[FTimeBillingSub].[Form]![Text21]
IS
ITS CONTROL SOURCE )

I note that you're testing the value of Text355 in order to set the
visible
property of Text335? Is this correct? (YES) You don't mean to test
Text355 and set
the visible property of Text355? (NO)

Did you try putting a breakpoint on the code so that it stops on the
If
..
then statement? (YES) When it does, put cursor over the Text355
word
and see what
value it has ... is it the value that you expect?

I'm not sure what you mean by the other post where you say
Text355
is
(can
be?) a negative number? (THE NUMBER IN IT SAYS -30 instead of 30 )
Are
you saying that the test for zero should look at
it being not exactly zero instead of greater than zero? Or did you
mean
that
you want to see if Text355 is less than 31 and Text335 is not
equal
to
zero?

You earlier said that the value of *the* "field" is
=[BidA]*0.02 (TEXT335 CONTROL SOURCE IS [Bid]*0.02 )
Which control (not field) has this as its control source? (TEXT335)

I'm afraid that my confusion is growing and I need some clarification,
please. Thanks.
--

Ken Snell
<MS ACCESS MVP>



Still didn't work, it is visible even if Text355 is greater than
30.
Should default value of Text335 be set to visible or not, does this
make
a
difference? Under it's properties I mean.


Try this:

If Text355 > 0 And Text355 < 31 Then
Text335.Visible = True
Else
Text335.Visible = False
End If

--

Ken Snell
<MS ACCESS MVP>

Ok, got it kinda. the problem is that Text335 equals a value
and
it
still
show a value even if it is $0.00
Is there a way to make it be invisible even if the value
is
0
as
well
as
If Text355 <31 Then
Text335.Visible = True
Else
Text335.Visible = False
End If

Below is the Value of the field, it is a calculated field.

=[BidA]*0.02

Tried that, didn't work

message
Try putting the code on the OnCurrent event of the main
form.

--

Ken Snell
<MS ACCESS MVP>

message
Text335 value is currency if this makes a difference
Also I tried putting a Text Box on the main form
TimeCards
named
Text355
which value is linked to Text box on sub-from
FTimeBillingSub
Text
Box
21
Then I put this code on the before update event for the
main
form
TimeCards
and it still did not work.

If Nz(Me.Text355) < 31 Then

Me.Text335.Visible = True

Else
Me.Text335.Visible = False
End If





message
I'm guessing that the code is not running when you think
it's
supposed
to
be
running. Try putting a breakpoint on the
If Nz(Me.FTimeBillingSub.Form!Text21) < 31 Then
line and see if the code actually runs when you expect
it
to.

Likely you'll need to put this code on a different
event,
but
I
am
not
sure
which one to recommend yet based on what you've posted.
I
am
not
sure
which
"value" is changing and therefore what should trigger
the
code
to
run.

--

Ken Snell
<MS ACCESS MVP>

in expect on
 
Back
Top