Setfocus inside form_keypress event sometimes fails

  • Thread starter Thread starter JT
  • Start date Start date
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
 
Never mind. I lied about the "control is capable of receiving the
focus..." part. It was disabled and locked. Duh.
 
Back
Top