R
Rich1234
I have a main form "A" with a subform "B." When a button, "lock/unlock" on
form A is pressed, one existing button on subform B is set to invisisble and
two other command buttons are set to visible.
Here is the problem:
After one of these command buttons is pressed, another form "C" opens in a
new window where the user can view or edit data. When the user returns to
the main form and subform "B" by closing form "C", the command button they
used to open form C still has the focus.. so when I click the lock/unlock
button on form A, I get the error, "You can't hide a control that has the
focus."
I know there are a few possible solutions to this one. I want to change the
focus to a textbox, "VRM" on the main form A whenever the lock/unlock button
is pressed. In VB for the lock button onclick event I have tried
Me.VRM.SetFocus
Me.Subform_B_Name.Form.Controls![CommandButton].Visible = IIf(bAllow,
"False", "True")
but it doesn't solve the problem. The Me.VRM.SetFocus doesn't seem to have
any effect (in that the control previously pressed still generates the error.)
What am i doing wrong here? Do I need to put something else before the
Me.VRM.SetFocus? (Is it something to do with the fact that the buttons
hidden are in the subform and the lock button is on the main form?) There are
lots of things that are toggled between visible/invisible when the lock
button is pressed and rather than coding each one individually, I just want
to reset the focus to a textbox on the main form when the lock button is
pressed.
TIA
rich
form A is pressed, one existing button on subform B is set to invisisble and
two other command buttons are set to visible.
Here is the problem:
After one of these command buttons is pressed, another form "C" opens in a
new window where the user can view or edit data. When the user returns to
the main form and subform "B" by closing form "C", the command button they
used to open form C still has the focus.. so when I click the lock/unlock
button on form A, I get the error, "You can't hide a control that has the
focus."
I know there are a few possible solutions to this one. I want to change the
focus to a textbox, "VRM" on the main form A whenever the lock/unlock button
is pressed. In VB for the lock button onclick event I have tried
Me.VRM.SetFocus
Me.Subform_B_Name.Form.Controls![CommandButton].Visible = IIf(bAllow,
"False", "True")
but it doesn't solve the problem. The Me.VRM.SetFocus doesn't seem to have
any effect (in that the control previously pressed still generates the error.)
What am i doing wrong here? Do I need to put something else before the
Me.VRM.SetFocus? (Is it something to do with the fact that the buttons
hidden are in the subform and the lock button is on the main form?) There are
lots of things that are toggled between visible/invisible when the lock
button is pressed and rather than coding each one individually, I just want
to reset the focus to a textbox on the main form when the lock button is
pressed.
TIA
rich