Force Data Entry

G

Guest

I have a combo box that populates other boxes on a form, works beautifully.
There is no reason a user would click elsewhere on the form and start
entering data, but we all know someone will do that. I have protections to
prevent adding records with null values to tables, so the data is reasonably
safe, but I need to make the operation of the form foolproof.

When the form opens, it defaults to the correct combo box. I have a message
box that fires on loss of focus if the combo box is null telling the nut to
go back and select from the dropdown, but the curser goes to the next in line
box. I would like to put the curser back in the first combo box. If I could
get it to do that I'd be fine.

I've tried using on gaining focus in the second box to go back to the first,
and it works but it also opens up other problems. I don't want to wait until
the user selects the save record command button or wait for the update record
event to validate whether this field is null or not, this form has many
controls., and many of them will not work unless the user selects the
customer from the first combo. I've been able to force people to stay in
check box fields and option groups, but haven't figured out how to force them
to enter data in the combo box before moving on. I've also tried to validate
the box is not null on loss of focus and return to that box but I get errors
that say I can't set focus or alternatively, can't use goto on an empty box.
I've also thought of making all controls invisible or locked until the combo
box is populated, but that all seems too complicated.

I know there is an easy answer. Clearly, I've either left something out or
my code, or I'm barking up the wrong tree.

Any ideas?
 
P

Pat Hartman\(MVP\)

Relying on the Lost Focus event to check for data entry assumes that the
cursor was ever in the field and so is not reliable. You MUST have edit
code in the form's BeforeUpdate event to handle this situation.

If you want to just tickle the user, you can add the edit to the Lost Focus
event but as you can see, you have trouble with setting the focus back to
the empty field. The solution is to set focus to some other control and
then set it back to the combo but don't take the code out of the form's
BeforeUpdate event and don't forget to cancel the update. You won't have
any trouble setting focus from that event.
 

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

Similar Threads


Top