INVISIBLE IF NO DATA (1 Viewer)

ALAN

Registered User.
Local time
Today, 13:21
Joined
Jul 12, 2000
Messages
23
How to make a field automatically invisible if no data (#Num) for that field.
 
R

Rich

Guest
If (IsNull(Me.YourTxtbox)) Then
Me.YourTxtbox.Visible = False
Else
Me.YourTxtbox.Visible = True
End If
HTH
 

ALAN

Registered User.
Local time
Today, 13:21
Joined
Jul 12, 2000
Messages
23
Thanks Rich, but where should I put this statement....I've tried it in "On No Data" and "On Error", the field still visible..For your information, actually the field is a result of 0 divided by 0. Hope to hear from you soon......Thanks in advance..
 

ALAN

Registered User.
Local time
Today, 13:21
Joined
Jul 12, 2000
Messages
23
The field still visible....actually the format is "percent"....anyway I had cancelled it to try this statement...it did not work...help me some more plz.....
 

KevinM

Registered User.
Local time
Today, 13:21
Joined
Jun 15, 2000
Messages
719
What is being displayed?

0, Nothing (null) or an error?

Rich's code should work, but it may need to be modified to accomodate for what is being displayed (above)
 

ALAN

Registered User.
Local time
Today, 13:21
Joined
Jul 12, 2000
Messages
23
The display is #Num!....I'm waiting....Thanks in advance...

[This message has been edited by ALAN (edited 05-26-2001).]
 
R

Rich

Guest
This article will explain the reason for your error
Article ID: Q112103
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 08:21
Joined
Feb 19, 2002
Messages
43,484
ALAN and others,
Please don't post the same question in multiple places. You just waste the time of people who are trying to help YOU. There is another thread for this question where it was answered.

To recap, the problem was caused by a divide by 0 exception so you need to prevent the division operation when the divisor is 0 or null.

IIf(Nz(YourField1,0) = 0, 0, YourField2/YourField1)
 

ALAN

Registered User.
Local time
Today, 13:21
Joined
Jul 12, 2000
Messages
23
Its really work.....Thanks Rich, Kevin and Pat...I'm sorry if I had caused difficulties ...I'm too eager to solve my problem...I am glad I had solved it ....thanks to all of you...
 

ALAN

Registered User.
Local time
Today, 13:21
Joined
Jul 12, 2000
Messages
23
IIf(Nz(YourField1,0) = 0, me.invisible, YourField2/YourField1)
What's wrong with this statement? Help me plz...
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 08:21
Joined
Feb 19, 2002
Messages
43,484
The IIf() is a function. Functions return values. They do not set properties. Although the IIf() function can be used to make decisions, it is not the same as the If..Then..Else statement.

The way your original post was worded, the IIf() was appropriate since it was to be used as the control source of a text box. Put the following into the Format event of the detail section:

If Nz(YourField1,0) = 0 Then
me.YourField.Visible = False
else
me.YourField.Visible = True
Me.YourField = YourField2/YourField1
End If
 

ALAN

Registered User.
Local time
Today, 13:21
Joined
Jul 12, 2000
Messages
23
Thanks Pat...It Works....Thanks again...
 

Users who are viewing this thread

Top Bottom