title: How to hide button control in VBA
body: <p>Is there anybody out here still programming VBA?</p>
  
  <p>I'm trying to get this code to work</p>
  
  <pre class="lang-vb prettyprint-override"><code>Private Sub button3_click()
  
      'hide main buttons
      button1.Visible = False
      button2.Visible = False
      button3.Visible = False
  
      'show submenu buttons
      button4.Visible = True;
      button5.Visible = True;
  
  End Sub
  </code></pre>
  
  <p>What I'm trying to do basically is that I have a main form that has 5 main button controls.  2 of them are hidden on startup.  So when I click button 3, I want to hide the first 3 main buttons, and "unhide" the other two.
  When trying to execute this event, I got an error </p>
  
  <p>"<strong>Runtime Error 2165 - You can't hide a control that has the focus</strong>".</p>
  
  <p>Has anybody come across this aspect of programming before?  I'm sure it's doable.  I just don't understand what went wrong here...</p>