Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 405
  • Last Modified:

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.


0
brant9274
Asked:
brant9274
1 Solution
 
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
 
omgangCommented:
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
 
omgangCommented:
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

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now