In the module associated with your form, create a routine along the lines
of:
Function ControlVisibility()
If Screen.ActiveControl = "NameOfCommandButton" Then
Me!NameOfAdjacentField.SetFocus
End If
Me!NameOfCommandButton.Visible = (Me!NameOfAdjacentField & vbNullString =
"Yes")
End Function
(replace NameOfAdjacentField and NameOfCommandButton with the appropriate
names)
If you have no other code in your form, you can simply call that function
for the form's Current event and for the text box's AfterUpdate event by
putting =ControlVisibility() (including the equal sign and parentheses) for
the event property. If you do have other code, call that function in your
form's Current event, as well as in the AfterUpdate event of the "adjacent
field":
Private Sub Form_Current()
Call ControlVisibility
' other code goes here...
End Sub
Private Sub