Closing a form Error

A

Al

I am trying to run "docmd.close" to close a form when a text box on the form
loses focus. I keep getting, can not perform command while processing form or
report. Is there a way to close a form when any control on the form loses or
get focus?
thanks
Al
 
J

Jeanette Cunningham

Hi Al,
what is the reason for wanting to close a form when a control loses focus?


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
A

Al

I have 5 forms where a user enters data from questionnaires. all foms are set
up so that when the user go the last text box and enter data then hits tab,
the next form opens right away and so on. It was a client request to do it
this way for speed. They do not want to go a click buttons to open and close
forms. On the last form, I want to close that form and go back to the main
menu in the same fashion; when the user reaches the last text box and tabs
out, the form closes and main menu appears. By the way, all 5 forms are sub
forms to a main form, when the user moves from one form to another by hitting
the tab, I simply change the source object for the subform. that is why there
is no problem until I reach the last form.
Al
 
J

Jeanette Cunningham

Here is an idea - untested!
Make the last control on the last form a command button.
When user tabs out of the last data entry control, use a set focus to set
focus to the command button.

You may be able to use the enter event of the command button to close the
form.
This will avoid the error when trying to use the lost focus event for a data
entry control.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
A

Al

Hi Jeanette,
thank you so much for your help. I actually, tried this before but in the
"On Got Focus" of the command button and it gave me the same error message. I
tried it now again as u suggested, behind the "On Enter" event. Same thing. I
find this interesting. I did not expect that a simple issue like closing a
form to be that complicated and to be limited to On Click event only. Any
ideas?
 
J

Jeanette Cunningham

That is why there are On Click events.
You could have 2 buttons, one to close the form, one to start a new record.
As long as the user clicks one of the 2 buttons they have a choice.
I suggest that fiddling around with the got focus and enter events is just a
waste of time.
Tabbing through data entry controls is fine, however a button to close the
form makes life easier.

Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 

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