SetFocus Question

G

Guest

I am having a problem that the focus would not return to the control when the
SetFocus was included in the AfterUpdate event of that control. I search
this group and found a solution that was basically to change focus to another
control then back to the desired control.

That solution works fine for me except for one problem. I have two controls
that I am using the AfterUpdate event and the SetFocus. One is the first
control in the tab order, the other is the last. My AfterUpdate event works
fine moving the focus back to the control on the "first" control, but does
not work on the "last". That is where I had to use the solution I mentioned
above.

It does not make sense to me that the SetFocus would work when the tab order
is the first, but not work when the tab order is the last. Can someone offer
some insight as to why this might happen?

Thanks.
 
K

Ken Snell \(MVP\)

I assume that you want to put the focus back on the textbox for a reason?
Post more details about what you are wanting to do. I'm sure we can suggest
a way to do what you seek.
 
G

Guest

For both controls, I want to make sure that the entry does not already exist
in the table. If it does, I dsiplay a message and I want the focus to return
to the control that was in error. I do all this in the AfterUpdate event of
the control.

Everything works fine except that the SetFocus does not seem to work
consistently. One control works, the other does not (unless I use the
solution I found in the group). The only differece I can see is the tab
order.
 
T

tina

suggest you check for duplicate entries in the control's BeforeUpdate event.
if the data fails the test, then set

Cancel = True

which will stop the update and the focus will remain in the control.

hth
 

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

Top