Closing A Form - options?

G

Guest

Hi everyone,

I am attempting to have a form auto-close either by tabbing through the last
field available on it, or by a button. I can get the button command to work
by using an onClick DoCmd.Close, however, if the user tabs through the
button, it opens a new record in the table it is linked to, which I do not
want it to do. Is there a way I can make the form close automatically once
the last field is tabbed through or prevent people from tabbing back to tab
stop 0?

When I remove the button, I have tried using the different options, such as
onExit, onChange and OnLostFocus, however, it either allows you to tab
through or I get a Runtime Error 2585 (Action cannot be carried out while
processing a form or report event)

With the button, I can get it to close the form with the click, but would
like to prevent the user from tabbing through this button.

Any help would be appreciated, thanks!

-gary
 
G

Guest

I think you can solve this by setting the form's Cycle property to 1 (Current
Record) which means if they tab through every control on the form, it will
not go to another record, it will go back to the first control on the form.

If you don't want them to move off the record, you will have to disable the
navigation buttons and record selectors as well.
 
G

Guest

Awesome! That works and solves my issue, but I have a follow up question.
Is there any way to actually have the tab cycle stop and not have it go back
to the first control or possibly have the form close once the last control is
tabbed through?

Thanks again!
-gary
 
G

Guest

Well, you could code the lost focus event of the last control in the tab
order to close the form, but there are some problems. Basically, you can't
control the order what the user is going to do. To avoid missing data in a
form because the user went to the last control before the record is complete,
you have to do some validation in the Before Update event of the form to be
sure you got everything. I think all this will do is frustrate the user.
Maybe they need to go back and make a correction. What if the just sit there
and punch the tab key (who knows what evil lurks in the minds of users)?

So, although is is doable, it would take a lot of code, and would only cause
problems.
 
G

Guest

aaah yes, evil users... ;)
thanks for the help!

Klatuu said:
Well, you could code the lost focus event of the last control in the tab
order to close the form, but there are some problems. Basically, you can't
control the order what the user is going to do. To avoid missing data in a
form because the user went to the last control before the record is complete,
you have to do some validation in the Before Update event of the form to be
sure you got everything. I think all this will do is frustrate the user.
Maybe they need to go back and make a correction. What if the just sit there
and punch the tab key (who knows what evil lurks in the minds of users)?

So, although is is doable, it would take a lot of code, and would only cause
problems.
 

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