CONTROL PROPERTIES VISIBLE = NO (HIDING CONTROLS)

  • Thread starter Thread starter TAZ1NOLES
  • Start date Start date
T

TAZ1NOLES

I have tried the following 2 sets of Event Procedures to hide fields on a
form when the data in another control = NO but no matter what I do the fields
still appear on the form & the print preview. Any thoughts or assistance
would be greatly appreciated!

***********************************************************

Private Sub CABLE_TAGS_PRESENT_AfterUpdate()
If Me.[CABLE_TAGS_PRESENT] = "No" Then
Me.[CABLE_TAGS_READABLE].Visible = False
Else: Me.[CABLE_TAGS_READABLE].Visible = True
End If

End Sub

***********************************************************

Private Sub PRIMARY_CABLE_REPLACEMENT_AfterUpdate()
If Me.[PRIMARY CABLE REPLACEMENT] = "No" Then
Me.[PRIMARY CABLE COMMENTS].Visible = False
Me.[CABLE_FEEDER__1].Visible = False
Me.[CABLE_FEEDER__2].Visible = False
Me.[CABLE_FEEDER__3].Visible = False
Me.[CABLE_FEEDER__4].Visible = False
Else: Me.[PRIMARY CABLE COMMENTS].Visible = True
Me.[CABLE_FEEDER__1].Visible = True
Me.[CABLE_FEEDER__2].Visible = True
Me.[CABLE_FEEDER__3].Visible = True
Me.[CABLE_FEEDER__4].Visible = True
End If

End Sub
 
Could your control CABLE_TAGS_PRESENT be boolean? If so, compare it to FALSE
rather than "No". If it is text, then "No" should work. Have you stepped
through the code? (Set a breakpoint on the line with
Me.[CABLE_TAGS_READABLE].Visible = False and step through the process. Do
you get any errors? Does the code run?

Also, this will only run after a change in the CABLE_TAGS_PRESENT value on
the form. If this field is stored, then you will not see the fields hidden
when you open the form unless you also call this code on the form current
event.
 
This is in answer to the 3 posts from Linq-DarylS & Scott04

1) I took off the brackets & it didn't help!
2) All of these fields are text & NO is an answer criteria of the CABLE TAGS
PRESENT field!
3) I tried adding the code to the OnCurrent event of the form & it didn't
make any difference.
4) With the brackets off I received errors about usage of Me.
5) I had to eliminate the Else: statement or received errors also.

Relatively back to square 1.

Thanks for your & any other help!
 
TAZ1NOLES -

I think it is because of the colon after the Else in your code (both
places). Access is probably treating the Else: as a label, which is ignored
in sequential processing. You could tell this be stepping through the code
while it is running. Anyway, try setting the Else on its own line without
the colon, like this:

Private Sub CABLE_TAGS_PRESENT_AfterUpdate()
If Me.[CABLE_TAGS_PRESENT] = "No" Then
Me.[CABLE_TAGS_READABLE].Visible = False
Else
Me.[CABLE_TAGS_READABLE].Visible = True
End If
 
Back
Top