How to hide the details in a report?

J

John T

Can anyone please help me here?

I have a report that is grouped by a field "Group". I would like to hide
the details when "Group" does not equal to "01". I know how to hide the
details but not sure how to evaluate the field though.

Thank you!
 
M

Marshall Barton

John T said:
I have a report that is grouped by a field "Group". I would like to hide
the details when "Group" does not equal to "01". I know how to hide the
details but not sure how to evaluate the field though.


Use the details section's Format event:

Cancel = (Me.Group <> "01")
 
J

John T

Thanks Marshall for your help! However, I still get the details when "Group"
not equal to "01".

My original code was:

Private Sub Report_Open(Cancel As Integer)

If Me.Group <> "01" Then
Me.Detail.Visible = False
End If

End Sub


I got an error message saying that "Run-time error '2427': You have entered
an expression that has no value."

I just could figure out why there's no value.
 
M

Marshall Barton

Are you sure the group field is a **Text** field with the
string "01"? I guess you would not see any details if that
were not the case so maybe the problem is the use of the
name Group, which is a reserved word. Try changing the name
of the field to something else and see if that helps.

Your code to set the Visible property needs to set Visible =
True if the group value is "01":

Me.Detail.Visible = (Me.Group = "01")

But this will have the same problem as my suggested code so
I don't see how that can help.

In general, this is a simple issue with no associated
problems so you must have something funny going on.
 
J

John Spencer

Try the following

Me.Section(0).Visible = Me.[Group] <> "01"

Marshall said:
Are you sure the group field is a **Text** field with the
string "01"? I guess you would not see any details if that
were not the case so maybe the problem is the use of the
name Group, which is a reserved word. Try changing the name
of the field to something else and see if that helps.

Your code to set the Visible property needs to set Visible =
True if the group value is "01":

Me.Detail.Visible = (Me.Group = "01")

But this will have the same problem as my suggested code so
I don't see how that can help.

In general, this is a simple issue with no associated
problems so you must have something funny going on.
--
Marsh
MVP [MS Access]

John said:
Thanks Marshall for your help! However, I still get the details when "Group"
not equal to "01".

My original code was:

Private Sub Report_Open(Cancel As Integer)

If Me.Group <> "01" Then
Me.Detail.Visible = False
End If

End Sub


I got an error message saying that "Run-time error '2427': You have entered
an expression that has no value."

I just could figure out why there's no value.
 

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