Code to make a Command box not visible

  • Thread starter Thread starter Anthony Dowd
  • Start date Start date
A

Anthony Dowd

Hi

Does anyone know how to make a command button invisible under a given
condition.

for example:

Private Sub Remove_Filter_Click()

If (FilterOn = True) Then

DoCmd.ShowAllRecords

Else
Remove_Filter.Visible = False '???????
End If

End Sub

Thanks
Anthony
 
The code
Remove_Filter.Visible = False
is correct but you cannot make a control invisible when it
has focus. You will have to set the focus on another
control before setting the visible to False.
e.g.
Private Sub Remove_Filter_Click()

If (FilterOn = True) Then

DoCmd.ShowAllRecords

Else
someothercontrol.SetFocus
Remove_Filter.Visible = False
End If

End Sub

On a point on aesthetics, it may be preferable to disable
the button rather than make it disappear.
e.g.
Remove_Filter.Enabled = False

Hope This Helps
Gerald Stanley MCSD
 
Thanks Gerald
Gerald Stanley said:
The code
Remove_Filter.Visible = False
is correct but you cannot make a control invisible when it
has focus. You will have to set the focus on another
control before setting the visible to False.
e.g.
Private Sub Remove_Filter_Click()

If (FilterOn = True) Then

DoCmd.ShowAllRecords

Else
someothercontrol.SetFocus
Remove_Filter.Visible = False
End If

End Sub

On a point on aesthetics, it may be preferable to disable
the button rather than make it disappear.
e.g.
Remove_Filter.Enabled = False

Hope This Helps
Gerald Stanley MCSD
 
Back
Top