Setfocus inside form_keypress event sometimes fails

J

JT

Using A2k, I examine keyboard input in a form_keypress event and
setfocus to an appropriate control. Sometimes Access complains "cannot
set focus to specified control". It seems to be timing related - if I
break at that point and repeat the setfocus line it works fine.

The control receiving the focus is obviously capable of receiving the
focus, and didn't just get to that state - not much exciting is going
on in the preceding lines of code:

ItemTypeText.Locked = True
ItemVal = IIf(SpecialCode < 65, 0, SpecialCode - 65)
HiddenLastAddedItemType = ItemVal
ItemTypeText.Value = ItemTypeString(ItemVal)
ISBNText.SetFocus

Thanks for your comments,

John
 
J

JT

Never mind. I lied about the "control is capable of receiving the
focus..." part. It was disabled and locked. Duh.
 

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