GK in the UK
Registered User.
- Local time
- Today, 18:10
- Joined
- Dec 20, 2017
- Messages
- 281
Is there a way to close a form from within a sub that has a Cancel parameter?
I want to Close a form within the Exit event of a textbox.
I get Error 2585, This action can't be carried out while processing a form or report event.
I'm trying to close with DoCmd.Close acForm, Me.Name
I don't need to save anything. I preceded the call to my Close sub with a Me.Undo
Anticipating the 'Why do I want to do this?':
My form has a textbox for input of an Account key which is mandatory, and it's the first field on the form.
It's a real pain if I open the form and change my mind, I can't close it until I've entered a valid Account key and moved to the next field.
So - I removed the requirement to have a valid Account key in the sub which deals with the lookup. Then, if there is no Account key, I call Cancel = true in the Exit event of the Account key field Exit event..
The effect of this is that if the Account key isn't valid, I pop up a message box, within the Exit event of the Account key field, and it has a Retry/Cancel option.
On press of Cancel, I want to Close the form.
I want to Close a form within the Exit event of a textbox.
I get Error 2585, This action can't be carried out while processing a form or report event.
I'm trying to close with DoCmd.Close acForm, Me.Name
I don't need to save anything. I preceded the call to my Close sub with a Me.Undo
Anticipating the 'Why do I want to do this?':
My form has a textbox for input of an Account key which is mandatory, and it's the first field on the form.
It's a real pain if I open the form and change my mind, I can't close it until I've entered a valid Account key and moved to the next field.
So - I removed the requirement to have a valid Account key in the sub which deals with the lookup. Then, if there is no Account key, I call Cancel = true in the Exit event of the Account key field Exit event..
The effect of this is that if the Account key isn't valid, I pop up a message box, within the Exit event of the Account key field, and it has a Retry/Cancel option.
On press of Cancel, I want to Close the form.