Code to make a Command box not visible

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
 
G

Gerald Stanley

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
 
A

Anthony Dowd

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top