Hide Fields on Reports based upon criteria

B

bondtk

This should be a very simple thing to do, but I'm running into the all famous
2427 error code. I want to hide a field if a checkbox is checked. So here
is my present code.

Sub
If [Proposal?]=-1 then Me.adminstamp.visible=false
End Sub

I put the [Proposal?] checkbox field on the report just in case that was the
issue but still get the same error 2427 "You entered an expression that has
no value"

This type of code was easy to put on a form, but the report doesn't like it.
Help!
 
O

Ofer

Did you put this code on the On format event of the section where both fields
are located in?
 
B

bondtk

Well, we're getting a little closer. Now I don't get the error. BUT now the
field is not visible regardless of the value of [Proposal?] Here's my exact
code.

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If [Proposal?] = -1 Then Me.Admin_Stamp.Visible = False
End Sub

Ofer said:
Did you put this code on the On format event of the section where both fields
are located in?
--
If I answered your question, please mark it as an answer. That way, it will
stay saved for a longer time, so other can benifit from it.

Good luck



bondtk said:
This should be a very simple thing to do, but I'm running into the all famous
2427 error code. I want to hide a field if a checkbox is checked. So here
is my present code.

Sub
If [Proposal?]=-1 then Me.adminstamp.visible=false
End Sub

I put the [Proposal?] checkbox field on the report just in case that was the
issue but still get the same error 2427 "You entered an expression that has
no value"

This type of code was easy to put on a form, but the report doesn't like it.
Help!
 
O

Ofer

It becuase you never set it back to true, try this
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If [Proposal?] = -1 Then
Me.Admin_Stamp.Visible = False
else
Me.Admin_Stamp.Visible = True
End if
End Sub
=====================================
Or
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Me.Admin_Stamp.Visible = Not ([Proposal?] = -1)
End Sub


--
If I answered your question, please mark it as an answer. That way, it will
stay saved for a longer time, so other can benifit from it.

Good luck



bondtk said:
Well, we're getting a little closer. Now I don't get the error. BUT now the
field is not visible regardless of the value of [Proposal?] Here's my exact
code.

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If [Proposal?] = -1 Then Me.Admin_Stamp.Visible = False
End Sub

Ofer said:
Did you put this code on the On format event of the section where both fields
are located in?
--
If I answered your question, please mark it as an answer. That way, it will
stay saved for a longer time, so other can benifit from it.

Good luck



bondtk said:
This should be a very simple thing to do, but I'm running into the all famous
2427 error code. I want to hide a field if a checkbox is checked. So here
is my present code.

Sub
If [Proposal?]=-1 then Me.adminstamp.visible=false
End Sub

I put the [Proposal?] checkbox field on the report just in case that was the
issue but still get the same error 2427 "You entered an expression that has
no value"

This type of code was easy to put on a form, but the report doesn't like it.
Help!
 
B

bondtk

You're a genious!!! Thank you very much. It works. Just can't leave out
both sides of the "else".

Ofer said:
It becuase you never set it back to true, try this
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If [Proposal?] = -1 Then
Me.Admin_Stamp.Visible = False
else
Me.Admin_Stamp.Visible = True
End if
End Sub
=====================================
Or
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Me.Admin_Stamp.Visible = Not ([Proposal?] = -1)
End Sub


--
If I answered your question, please mark it as an answer. That way, it will
stay saved for a longer time, so other can benifit from it.

Good luck



bondtk said:
Well, we're getting a little closer. Now I don't get the error. BUT now the
field is not visible regardless of the value of [Proposal?] Here's my exact
code.

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If [Proposal?] = -1 Then Me.Admin_Stamp.Visible = False
End Sub

Ofer said:
Did you put this code on the On format event of the section where both fields
are located in?
--
If I answered your question, please mark it as an answer. That way, it will
stay saved for a longer time, so other can benifit from it.

Good luck



:

This should be a very simple thing to do, but I'm running into the all famous
2427 error code. I want to hide a field if a checkbox is checked. So here
is my present code.

Sub
If [Proposal?]=-1 then Me.adminstamp.visible=false
End Sub

I put the [Proposal?] checkbox field on the report just in case that was the
issue but still get the same error 2427 "You entered an expression that has
no value"

This type of code was easy to put on a form, but the report doesn't like it.
Help!
 
Top