Focus Issue

B

Bob Quintal

I need to set a command button's visibility to
FALSE when it receives the focus.

No, you need to set the button's visibility to False, AFTER it has
received focus and done something, because the code under the button
won't ever get executed if you make it not visible during the
OnGetFocus Event.

So, I first
need to move the focus to some innocuous
control, most desirably the form itself. I've
tried Me.Form.SetFocus, but that doesn't
seem to have any affect. What's the expression
to move the focus to the form?

The form cannot receive focus if there is any control on the form
which can get focus. One workaround is an empty textbox, in the
upper left corner of the form, with 0 width and 0 height.
Thanks,
Bill
 
B

Bill

I need to set a command button's visibility to
FALSE when it receives the focus. So, I first
need to move the focus to some innocuous
control, most desirably the form itself. I've
tried Me.Form.SetFocus, but that doesn't
seem to have any affect. What's the expression
to move the focus to the form?

Thanks,
Bill
 
R

Rick Brandt

Bill said:
I need to set a command button's visibility to
FALSE when it receives the focus. So, I first
need to move the focus to some innocuous
control, most desirably the form itself. I've
tried Me.Form.SetFocus, but that doesn't
seem to have any affect. What's the expression
to move the focus to the form?

Thanks,
Bill

The form cannot get focus if there is any control on the form capable of getting
focus. Use some other control instead.
 
B

Bill

Another thought, can I set the focus to the
"record selector"? There's no control per se'
in the design view, so I don't know how one
would address it. But, clearly I can put the
focus on the selector bar when in interactive
mode with the form.
Bill
 
G

Guest

Why don't you try having an already hidden textbox (or one small enough that
you can't see it or hidden in behind somthing else) and set the focus to that
 
T

tina

no. you'll need to move the focus off the command button to another control
in the form, as others have said.

hth
 
L

Linq Adams via AccessMonster.com

As has been stated you need a "phantom" textbox to use for this purpose.
Place a textbox on your form and either make a note of its name or name it
something you'll remember (like PhantomTextbox) then locate it in the left
upper corner of your form and shrink it down as small as possible. Being
minute and located in a corner of the form it will be essentially invisible.
Now, after the command button's code has fired, move the focus to your
phantom textbox and make the button invisible.

You need to understand, though, that the command button will now be invisible
until you do something to change it back to visible! If you move to another
record it will not be visible, unless you have code in the Form_Current event
to make it visible again. Likewise, if you close your form and then re-open
it, the button will be visible, even on the record that you just made it
invisible on, unless you have code in the Form_Current event that checks some
condition and sets its visibility accordingly.
 
B

Bill

Bob,
Your suggestion was the one I followed. These little
tidbits are always worth remembering, sort of like
when one has invisible controls on a report so that
the query fields can be referenced in code.
Thanks,
Bill
 
B

Bob Quintal

Bob,
Your suggestion was the one I followed. These little
tidbits are always worth remembering, sort of like
when one has invisible controls on a report so that
the query fields can be referenced in code.
Thanks,
Bill
An explanatory comment in the form's code module helps remember
particiularities of implementation.


Bob Quintal said:
No, you need to set the button's visibility to False, AFTER it has
received focus and done something, because the code under the button
won't ever get executed if you make it not visible during the
OnGetFocus Event.

So, I first

The form cannot receive focus if there is any control on the form
which can get focus. One workaround is an empty textbox, in the
upper left corner of the form, with 0 width and 0 height.
 
B

Bill

Oh! You can be sure I did that.......ALWAYS!

Bob Quintal said:
Bob,
Your suggestion was the one I followed. These little
tidbits are always worth remembering, sort of like
when one has invisible controls on a report so that
the query fields can be referenced in code.
Thanks,
Bill
An explanatory comment in the form's code module helps remember
particiularities of implementation.
 

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

Similar Threads


Top