Set focus problem

  • Thread starter lmcc via AccessMonster.com
  • Start date
L

lmcc via AccessMonster.com

I didn't think about all the possibilties. That's over my head. And, I am
following the example in the books I read, which does not address all the
various possibilities of closing a form.

The form is no longer getting that error message 3021.

There is no other code or macros behind the form.

Dirk said:
[quoted text clipped - 38 lines]
with
someone else.

You're welcome, but I don't think you should consider the matter settled
yet. Your code will successfully prevent closing the form and saving the
record if the agency is not chosen, but *only if the form is closed by your
cmdOK button*. What if the user closes the form by clicking the "X" button
in the title bar? What if the user presses Alt+F4, or clicks menu item
File --> Close to close the form? What if the user presses Shift+Enter to
save the record without closing the form, or clicks menu item Records ->
Save Record?

If you want to prevent an incomplete record from being saved, then you
really need to be using the form's BeforeUpdate event to do the validation.
Everything else is secondary. The code we had worked up before was fine, so
far as it went, except that something as yet unidentified was causing error
3021 to be raised. If I were in your position, I would be addressing that
specific error to identify its cause. *Then* you could decide whether to
fix it or ignore it.

To that end, I have asked you repeatedIy to post any other code or macros
behind the form, but you haven't done so. There's no guarantee that having
that information would let me solve the 3021 error, but not having it ties
my hands as far as helping you goes. All I can do at this point is warn you
that the code you posted above doesn't meet your requirements in all cases.
 
D

Dirk Goldgar

lmcc via AccessMonster.com said:
I didn't think about all the possibilties. That's over my head. And, I am
following the example in the books I read, which does not address all the
various possibilities of closing a form.

Not all books are created equal.
The form is no longer getting that error message 3021.

Good, but I would still recommend going back to the arrangement where you
use the BeforeUpdate event to validate the record before saving, and then
use the revised code I posted for your cmdOK button to trap and ignore both
error 2101 and 3021.
There is no other code or macros behind the form.

Thank you, that wasn't clear before.

Does the form have a subform? There are circumstances under which that can
cause error 3021 when you close the form.
 

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