Originally Posted by
ridders52
OK that's a separate issue. Open your form in design view.
Click Tab order in the Design ribbon. Look at the first item in the order for each section of the form
You are trying to hide one of the controls that are first in the list.
Either change the tag value for that control so it stays visible at first or change the order so one of the controls that stays visible is first
First off - thank you, I had no idea about checking "Tab Order".
I'm still a bit perplexed though because the first item in each section ("Form Header", "Detail", and "Form Footer") is tagged with "Default" - which is the tag that's being set to Visible in the Form_Load event.
Yet I'm still receiving the error message "Error 2165 - You can't hide a control that has the focus" when I click to open up the form.
The only thing I can think of is that that the error message is actually referring to something in the Main Menu of my database? There's a button on the Main Menu that opens up this particular form (as well as a couple others that produce the same error message).
Because if I simply tweak your code ("ShowControls") so that it only applies to this 1 specific form - as opposed to stating "For Each Ctrl in Screen.ActiveForm.Controls" - then oddly it works as intended. I also noticed that when it's referring to Screen.ActiveForm.Controls, a couple of the controls in my Main Menu Form are suddenly visible. But as far as the Main Menu Form is concerned, I haven't tagged *any* of the controls on it. In theory, the code should only be applied to a form in which the "Tag" property is being used (on 1 or more controls in that form), correct?
Code:
ShowControls True, "Default"
ShowControls False, "Hidden", "Completed"