Dec 8 2011, 09:52 AM
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.
Dec 8 2011, 10:44 AM
What 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?
Dec 8 2011, 10:52 AM
Sorry - added to my signature so I don't forget in the future - Access 2007
Currently it's a macro, bound form. The on-click event is Close (Save=yes).
Dec 8 2011, 11:08 AM
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...
Dec 8 2011, 11:24 AM
Perfect - here's what I landed with (attached).
Dec 8 2011, 12:19 PM
Good luck with your project.