Force combo box selection before moving off field

L

LauriS

I've searched through the group but I can't seem to find exactly what I'm
looking for.

Using 2000 ...

I have a combo box on a form. The row source is a simple query. The
control source is a long integer (link to an autonumber). Form is based on a
table.

I don't want the user to be able to move off the CB (combo box) unless they
select something from the list (or type in a new item).

I've tried making the control source required in the table. This won't let
them move off the RECORD until they do something in the CB. I want them
stopped at the CB.

I set up code to check the value of the control source (on exit) and if it's
0 display a msg box. Works great - but now I want to put them back at the
CB and I can't figure out how.

I can't use the setfocus option because it still moves off the CB.

Can't use the before or after update because if they just tab past the CB
there's no change and those events don't get triggered.

I think this should be simple and it's driving me nuts. Help!!

Lauri S.
 
R

ruralguy via AccessMonster.com

The OnExit event *is* triggered by tabbing and can be cancelled to hold the
focus in the control.
 
R

Ron2006

the cancelevent mentioned is probably the more proper way.

The other thing that I have done in some cases do a setfocus to some
other button or control and THEN do the setfocus back to the control I
want it to be on.

Ron
 

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