Full Version: Macro Error Handling - Missed Required Fields
UtterAccess Forums > Microsoft® Access > Access Macros
I have a "Submit" button on a form that contains required fields. The "Submit" button currently closes the form and requery's the form that the closed form was launched from. As it is currently, if I do not complete all required fields and click submit, it pops the error message about missing a required field, then a message prompting to close the form or not, then a macro failed message. Obviously not a good user experience, so just wondering if I can use macros to alter this behavior or if VBA would be required. I prefer macro, but either way, need some guidance.
Ideally, I would like the form to just pop once message stating that a required field was missed, with two buttons - one returns the user to the form to correct, the other closes the form without saving changes, and neither option would pop any further errors or failed macro windows.
Hi Bill,
That version of Access are you using? Knowing the Access version may help us determine a more appropriate response to your question.
You should be able to modify the code you have running behind your Submit button to check for required fields first before proceeding with the steps to close the form. For that button, are you using a macro or VBA?
Is this form bound or unbound?
Sorry - added to my signature so I don't forget in the future - Access 2007
urrently it's a macro, bound form. The on-click event is Close (Save=yes).
Thank you.
Then you should be able to add a Condition column to your macro to check if the required fields are empty or not and proceed with the form close appropriately. For example, you might try something like:
Condition: Len(Forms!FormName.ControlName & "") = 0
Action: RunCommand, Undo
Just my 2 cents... 2cents.gif
Perfect - here's what I landed with (attached).
Hi Bill,
Good luck with your project.
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.