Resetting Focus on an active cell in CellLostFocus

Hi Folks,

Trying to protect users from them selves and I catch a CellLostFocus event to keep the user from entering duplicate titles. In the CellLostFocus event, I pop up a MessageDialog explaining what they’ve done and then execute these lines of code:

Me.Cell(row, cell) = "Please name this tape set" Me.EditCell(row, cell) Me.ActiveCell.SelectAll

However, once I return from the CellLostFocus event, the cell is not active, nor selected. in the CellKeyDown and a couple of other locations, this works fine.

Ideas? Workaround?

LostFocus is the wrong place to be playing with focus. The best you can do is start a timer that will handle the focus change after the current event stack unwinds. I try as much as possible to catch Tab, Enter, Arrows, etc in KeyDown, before any focus change occurs. If the user clicks away, I give a warning, but let him go and mark this field as needing attention.

Thanks, Tim. I’d just come to the same conclusion about using a timer. Since I have to catch this situation if the user clicks out of the active cell, It will solve the issue.

Since both my Q/A team and I are so keyboard-oriented, I’d missed this one and we had users creating entries that conflicted and couldn’t figure out why. Finally got a ScreenFlow capture from one and caught it.