I've searched in this forum for some time and have not found my problem described although some folks have come close.
I have a form, 'Visitation Schedule' that is for user input. Data is actually entered in a subform that is displayed in datasheet view.
The subform has code in the BeforeUpdate event that checks for required fields and has the user complete the record correctly or undo's the record.
Back in the main form, I have this CLOSE command button. The code behind this button is just the docmd.Close with the name of the form.
When there is a partial record with some required fields not completed, here is what happens.
1) Close Form button is pressed
2) Code in subform BeforeUpdate event executes
3) Execution NEVER returns to the Close Form button.
When there is a complete record, then
1) Close Form button is pressed
2)Close form code executes
3) Form closes
In the first case, once the user either completes the record or decides to discard the record, then the Close Form is clicked on again, the form closes without question.
I don't mind the checking in BeforeUpdate but I don't understand why the execution does not return to the code behind the Close Form button.
Does anyone have a reasonable answer for why this is so? Or how I could talk the BeforeUpdate procedure to Close the form if the OnClose had been clicked (this is not always the case!).
I have a form, 'Visitation Schedule' that is for user input. Data is actually entered in a subform that is displayed in datasheet view.
The subform has code in the BeforeUpdate event that checks for required fields and has the user complete the record correctly or undo's the record.
Back in the main form, I have this CLOSE command button. The code behind this button is just the docmd.Close with the name of the form.
When there is a partial record with some required fields not completed, here is what happens.
1) Close Form button is pressed
2) Code in subform BeforeUpdate event executes
3) Execution NEVER returns to the Close Form button.
When there is a complete record, then
1) Close Form button is pressed
2)Close form code executes
3) Form closes
In the first case, once the user either completes the record or decides to discard the record, then the Close Form is clicked on again, the form closes without question.
I don't mind the checking in BeforeUpdate but I don't understand why the execution does not return to the code behind the Close Form button.
Does anyone have a reasonable answer for why this is so? Or how I could talk the BeforeUpdate procedure to Close the form if the OnClose had been clicked (this is not always the case!).