Only show a field when a certain value

  • Thread starter Thread starter whitjl143
  • Start date Start date
W

whitjl143

I have a report that I want to show the value of it when another field is a
certain value.

Field1 - Material
Field2 - LoadAt

I have the current code:
Me.LoadAt.Visible = Me.Material = "238" Or Me.Material = "239" Or
Me.Material = "240" Or Me.Material = "241" Or Me.Material = "242" Or
Me.Material = "243" Or Me.Material = "244" Or Me.Material = "245" Or
Me.Material = "246" Or Me.Material = "247" Or Me.Material = "248" Or
Me.Material = "249" Or Me.Material = "250" Or Me.Material = "251" Or
Me.Material = "252" Or Me.Material = "253" Or Me.Material = "254" Or
Me.Material = "255" Or Me.Material = "256" Or Me.Material = "257" Or
Me.Material = "258" Or Me.Material = "259" Or Me.Material = "260" Or
Me.Material = "261" Or Me.Material = "262" Or Me.Material = "263" Or
Me.Material = "264"

This works fine except if I add another material I have to keep going back
into the code to add the materialID there also. Is there a way to set this
up so the LoadAt field will print only if the Material is "Haul Only" (which
is the value of the Material field not the MaterialID).
 
whitjl143,

In the table where Material lives, I'd add another field to the table.
For example, a boolean True/False field called ShowLoadAt.
Set the ShowLoadAt = True, for all those Material nos that need LoadAt,
then in the report...
If Me.ShowLoadAt = True Then
Me.ShowLaodAt.Visible = True
Else
Me.ShowLaodAt.Visible = False
End sub
-- OR --
Me.ShowLoadtAt.Visible = Me.ShowLoadAt = True

The advantage to this is that when a new material is added... just set
the ShowLoadAt value, and no additional coding needed.
--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your life."
 
Back
Top