Code to display label on form if condition is met

I have a label on a form that is set to not be visible in format properties.  As I cycle through records with that form, I want that label to display if the destroyed field for that record is true.

Background info.

I have a field in table called destroyed.  It is set as a YES/NO field....which I believes it stores a 0 for no and a -1 for yes.

I have the following code setup to run when Form...Event...On Current

                 If destroyed <> 0 Then
                  Label92.Visible = True
                 Else
                  Label92.Visible = False
                  End If

I have tried every thing known to man and it does not work.  I was able to use the code below that looks at the ID key and it works.

If ID = 5 Then

Label92.Visible = True
Else
Label92.Visible = False

End If

Please help...thanks.


brant9274Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

stevbeCommented:
<As I cycle through records with that form, I want that label to display if the destroyed field for that record is true.>

Private Sub Form_Current()
    Me.Label93.Visible = Me.destroyed.Value
End Sub
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
omgangIT ManagerCommented:
Private Sub Form_Current()

    If Me.destroyed = True Then
        Me.Label92.Visible = True
    Else
        Me.Label92.Visible = False
    End If
   
End Sub

OM Gang
0
omgangIT ManagerCommented:
I like it stevbe (now why didn't I think of that)
0
thenelsonCommented:
Your code should work if the destroyed field is a yes/no field.  Place a code break on the line
               If destroyed <> 0 Then
and see what is in destroyed.
0
brant9274Author Commented:
Worked Perfect...Thanks.  It seems like my code should have worked though.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.