Visible Field

G

Guest

I have a field on a report that is formatted for currency and displays zero
dollars as the default.

What I would like is for the field to be NOT visible if it is zero and
visible if the amount exceeds zero.

The control source would need to use the IIf command. Whether it is to be
visible or not will depend on another field. EG:
IIf([Date]>0,Visible,NotVisible) Is there a code that will activate Visible
or Not Visible?

Thanks for any help
 
G

Guest

You can add some code in the On Current event of your form or report to
accomplish what you want. Something like;

If Me.FieldName = 0 Then

Me.FieldName.Visible = False

Else

Me.FieldName.Visible = True

End If

HTH
 
G

Guest

Thanks for that Beetle.

I have created an OnLoad Event procedure as follows:

Private Sub Report_Open(Cancel As Integer)
If Me.Text239 <= "23/06/3000" Then
Me.W53.Visible = True
Else
Me.W53.Visible = False
End If
End Sub

When I open the report I receive a 2427 error "You entered an expression
that has no value"

The problem appears to be that the [Text239] has an IIf Statement in the
control source. Is there any way around this?

Thanks again


Beetle said:
You can add some code in the On Current event of your form or report to
accomplish what you want. Something like;

If Me.FieldName = 0 Then

Me.FieldName.Visible = False

Else

Me.FieldName.Visible = True

End If

HTH

Roger Bell said:
I have a field on a report that is formatted for currency and displays zero
dollars as the default.

What I would like is for the field to be NOT visible if it is zero and
visible if the amount exceeds zero.

The control source would need to use the IIf command. Whether it is to be
visible or not will depend on another field. EG:
IIf([Date]>0,Visible,NotVisible) Is there a code that will activate Visible
or Not Visible?

Thanks for any help
 
G

Guest

In your first post you indicated that you were trying to use the IIf
statement to control the visibility of your text box. If that's the case,
just get rid of the IIf statement and use the code to control the visibility.
If that's not the case, and your IIf statement serves some other necessary
purpose, then post your exact IIf here and maybe myself or someone else can
help you solve your current problem.

Roger Bell said:
Thanks for that Beetle.

I have created an OnLoad Event procedure as follows:

Private Sub Report_Open(Cancel As Integer)
If Me.Text239 <= "23/06/3000" Then
Me.W53.Visible = True
Else
Me.W53.Visible = False
End If
End Sub

When I open the report I receive a 2427 error "You entered an expression
that has no value"

The problem appears to be that the [Text239] has an IIf Statement in the
control source. Is there any way around this?

Thanks again


Beetle said:
You can add some code in the On Current event of your form or report to
accomplish what you want. Something like;

If Me.FieldName = 0 Then

Me.FieldName.Visible = False

Else

Me.FieldName.Visible = True

End If

HTH

Roger Bell said:
I have a field on a report that is formatted for currency and displays zero
dollars as the default.

What I would like is for the field to be NOT visible if it is zero and
visible if the amount exceeds zero.

The control source would need to use the IIf command. Whether it is to be
visible or not will depend on another field. EG:
IIf([Date]>0,Visible,NotVisible) Is there a code that will activate Visible
or Not Visible?

Thanks for any help
 
G

Guest

The IIf statement in [text239] is as follows:

=IIf([text233]<="23/06/3000",[text233]+7,Null)

Thanks again

Beetle said:
In your first post you indicated that you were trying to use the IIf
statement to control the visibility of your text box. If that's the case,
just get rid of the IIf statement and use the code to control the visibility.
If that's not the case, and your IIf statement serves some other necessary
purpose, then post your exact IIf here and maybe myself or someone else can
help you solve your current problem.

Roger Bell said:
Thanks for that Beetle.

I have created an OnLoad Event procedure as follows:

Private Sub Report_Open(Cancel As Integer)
If Me.Text239 <= "23/06/3000" Then
Me.W53.Visible = True
Else
Me.W53.Visible = False
End If
End Sub

When I open the report I receive a 2427 error "You entered an expression
that has no value"

The problem appears to be that the [Text239] has an IIf Statement in the
control source. Is there any way around this?

Thanks again


Beetle said:
You can add some code in the On Current event of your form or report to
accomplish what you want. Something like;

If Me.FieldName = 0 Then

Me.FieldName.Visible = False

Else

Me.FieldName.Visible = True

End If

HTH

:

I have a field on a report that is formatted for currency and displays zero
dollars as the default.

What I would like is for the field to be NOT visible if it is zero and
visible if the amount exceeds zero.

The control source would need to use the IIf command. Whether it is to be
visible or not will depend on another field. EG:
IIf([Date]>0,Visible,NotVisible) Is there a code that will activate Visible
or Not Visible?

Thanks for any help
 
G

Guest

What is "23/06/3000"? It appears to be the European date format for June
23rd, 3000, altought I can't imagine why you need to track a date 1000 years
in the future, so I'm guessing it's something else (then again, maybe you're
trying to calculate when they will have all the bugs fixed in Windows Vista).

It could be that Access can't determine what it is, and therefore can't tell
if [text233] is less than or equal to it, so [text239] defaults to the
alternate choice in your IIf statement, which is null. Hence, you end up with
an expression that has no value. To test this, you could change it to:

=IIf([text233]<="23/06/3000",[text233]+7,0)

This will give it an alternate value of zero. Then see if your error message
goes away. If it does, then you know you're probably on the right track.

If "23/06/3000" does represent a date, then you might want to verify that
all of the fields you are using for your calculation are of the Date/Time
data type.

HTH

BTW - If you plan on working with Access much in the future, you should give
your fields more descriptive names. Months or years from know, you might
regret that your code is full of references like [text233] and [text239].
You'll spend a lot of extra time determining which controls they refer to.
Just a suggestion.

Roger Bell said:
The IIf statement in [text239] is as follows:

=IIf([text233]<="23/06/3000",[text233]+7,Null)

Thanks again

Beetle said:
In your first post you indicated that you were trying to use the IIf
statement to control the visibility of your text box. If that's the case,
just get rid of the IIf statement and use the code to control the visibility.
If that's not the case, and your IIf statement serves some other necessary
purpose, then post your exact IIf here and maybe myself or someone else can
help you solve your current problem.

Roger Bell said:
Thanks for that Beetle.

I have created an OnLoad Event procedure as follows:

Private Sub Report_Open(Cancel As Integer)
If Me.Text239 <= "23/06/3000" Then
Me.W53.Visible = True
Else
Me.W53.Visible = False
End If
End Sub

When I open the report I receive a 2427 error "You entered an expression
that has no value"

The problem appears to be that the [Text239] has an IIf Statement in the
control source. Is there any way around this?

Thanks again


:

You can add some code in the On Current event of your form or report to
accomplish what you want. Something like;

If Me.FieldName = 0 Then

Me.FieldName.Visible = False

Else

Me.FieldName.Visible = True

End If

HTH

:

I have a field on a report that is formatted for currency and displays zero
dollars as the default.

What I would like is for the field to be NOT visible if it is zero and
visible if the amount exceeds zero.

The control source would need to use the IIf command. Whether it is to be
visible or not will depend on another field. EG:
IIf([Date]>0,Visible,NotVisible) Is there a code that will activate Visible
or Not Visible?

Thanks for any help
 
G

Guest

Roger,

Where is the control you are trying to hide/make visible (Header, detail
section, footer) on the report.

My guess is that you will need to move the code to the Format event of the
detail section. In design view, click on the detail section divider and look
at the event properties. There is a Format event, expand it and enter the
code you used. Some people like to use the IF/Then format for this type of
thing. I prefer to use a logical statement that returns a True/False. In
the statement below, Access tests the value of me.text239 against 0 and if it
is <> 0, then it returns a True Value, setting the control to True,
otherwise, it returns False.

Private sub Detail_Format(Cancel as Integer, FormatCount as Integer)

me.W53.Visible = (me.text239 <> 0)

End sub

The only concern I have with this is that if the value in text239 is a
decimal value, you might have some rounding error at some very low number. A
way to check this and make sure that the value in the text field is less than
0.00 would be to use:

me.W53.Visible = (Format(me.text239, ".00" <> ".00")

--
Email address is not valid.
Please reply to newsgroup only.


Roger Bell said:
Thanks for that Beetle.

I have created an OnLoad Event procedure as follows:

Private Sub Report_Open(Cancel As Integer)
If Me.Text239 <= "23/06/3000" Then
Me.W53.Visible = True
Else
Me.W53.Visible = False
End If
End Sub

When I open the report I receive a 2427 error "You entered an expression
that has no value"

The problem appears to be that the [Text239] has an IIf Statement in the
control source. Is there any way around this?

Thanks again


Beetle said:
You can add some code in the On Current event of your form or report to
accomplish what you want. Something like;

If Me.FieldName = 0 Then

Me.FieldName.Visible = False

Else

Me.FieldName.Visible = True

End If

HTH

Roger Bell said:
I have a field on a report that is formatted for currency and displays zero
dollars as the default.

What I would like is for the field to be NOT visible if it is zero and
visible if the amount exceeds zero.

The control source would need to use the IIf command. Whether it is to be
visible or not will depend on another field. EG:
IIf([Date]>0,Visible,NotVisible) Is there a code that will activate Visible
or Not Visible?

Thanks for any help
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top