By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,089 Members | 2,283 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,089 IT Pros & Developers. It's quick & easy.

How to make control invisible when text value is zero?

P: n/a
I have a report with a text box named Discount. If this text box
shows a value of 0, I do not want the text box to be visible.

I have tried the following code, but it disables the control even when
the value is greater than zero. My IF statement seems to always be
true. Also, I can't find a value property for the text box.

I have searched and can't find the answer via Google.

Thanks.

Private Sub GroupFooter3_Format(Cancel As Integer, FormatCount As
Integer)
If Me.Discount = 0 Then
Discount.Visible = False
End If
End Sub

Jan 14 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Bill wrote:
>I have a report with a text box named Discount. If this text box
shows a value of 0, I do not want the text box to be visible.

I have tried the following code, but it disables the control even when
the value is greater than zero. My IF statement seems to always be
true. Also, I can't find a value property for the text box.

I have searched and can't find the answer via Google.

Thanks.

Private Sub GroupFooter3_Format(Cancel As Integer, FormatCount As
Integer)
If Me.Discount = 0 Then
Discount.Visible = False
End If
End Sub

There is not automatic thingie that sets Visible to True, so
you have to do it yourself:

If Me.Discount = 0 Then
Discount.Visible = False
Else
Discount.Visible = True
End If

Or, more concisely:

Discount.Visible = (Me.Discount <0)

--
Marsh
Jan 14 '07 #2

P: n/a
On Sun, 14 Jan 2007 16:50:17 -0600, Marshall Barton
<ma*********@wowway.comwrote:
>Bill wrote:
>>I have a report with a text box named Discount. If this text box
shows a value of 0, I do not want the text box to be visible.

I have tried the following code, but it disables the control even when
the value is greater than zero. My IF statement seems to always be
true. Also, I can't find a value property for the text box.

I have searched and can't find the answer via Google.

Thanks.

Private Sub GroupFooter3_Format(Cancel As Integer, FormatCount As
Integer)
If Me.Discount = 0 Then
Discount.Visible = False
End If
End Sub


There is not automatic thingie that sets Visible to True, so
you have to do it yourself:

If Me.Discount = 0 Then
Discount.Visible = False
Else
Discount.Visible = True
End If

Or, more concisely:

Discount.Visible = (Me.Discount <0)
I thought it was "automatic" because they are visible by default and
show up if no code is written?

I guess you are saying that when I change it to False, I have to
change it back when I want it to be True?

Thanks.
Jan 15 '07 #3

P: n/a
"Bill" <Bi**@yahoo.comwrote
I thought it was "automatic" because they are
visible by default and show up if no code is written?
That's almost true... the Visible property is set True by default, UNLESS
you change that Property in Design View. Whatever the value set in Design
View, will apply when the Form is first Opened in Form View. Once you change
it from its Design View setting, it will retain the value you set, until you
change that value or Close the Form. To set it _permanently_ to a different
value, you'd have to make the change in Design View.
I guess you are saying that when I change it to False, I have to
change it back when I want it to be True?
Yes, see above.

Larry Linson
Microsoft Access MVP

Jan 15 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.