Best way to require an entry and persist setting focus?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a combo box that has three values in it

SELECT
AP
CS

I'm trying to write code to require something be selected besides
'SELECT' which is the default.

If the user skips the box
I don't want to use the form's after update event to catch this error later,
I want it to immediately bounce back to the control if they skip it.

I've tried the lostfocus event like this:
if me.cboDptSelect = "SELECT" then
msgbox "Please select your department"
me.cboDptSelect.setfocus
end if

it's weird, it only works sometimes.
If I use my mouse to select another field, I get the message, but
It doesn't set focus back to the box

I don't want to write code in every other GotFocus box of my form to check
this.

Somehow, I always manage to get this to work serendipitously with various
methods, but there must be a standard way to provide "suction" to a required
control that is skipped.
 
I normally do it on the "exit" event. Then, I don't put a setfocus
statement, I simply put a...

Cancel=True


Which says, okay, you are about to exit the field, DON'T.

Hope that helps,

Rick B
 
Concise. Perfect. Thanks.

Rick B said:
I normally do it on the "exit" event. Then, I don't put a setfocus
statement, I simply put a...

Cancel=True


Which says, okay, you are about to exit the field, DON'T.

Hope that helps,

Rick B
 
Back
Top