UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Macro Error Handling - Missed Required Fields    
 
   
bmay1984
post Dec 8 2011, 09:52 AM
Post #1

UtterAccess Veteran
Posts: 378
From: Minnesota



Hi,

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.

Thanks,
Bill
Go to the top of the page
 
+
theDBguy
post Dec 8 2011, 10:44 AM
Post #2

Access Wiki and Forums Moderator
Posts: 48,058
From: SoCal, USA



Hi Bill,

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?
Go to the top of the page
 
+
bmay1984
post Dec 8 2011, 10:52 AM
Post #3

UtterAccess Veteran
Posts: 378
From: Minnesota



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).
Go to the top of the page
 
+
theDBguy
post Dec 8 2011, 11:08 AM
Post #4

Access Wiki and Forums Moderator
Posts: 48,058
From: SoCal, USA



QUOTE (bmay1984 @ Dec 8 2011, 08:52 AM) *
Sorry - added to my signature so I don't forget in the future - Access 2007

Thank you.


QUOTE
Currently it's a macro, bound form. The on-click event is Close (Save=yes).

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

(untested)
Just my 2 cents... (IMG:style_emoticons/default/2cents.gif)
Go to the top of the page
 
+
bmay1984
post Dec 8 2011, 11:24 AM
Post #5

UtterAccess Veteran
Posts: 378
From: Minnesota



Perfect - here's what I landed with (attached).

Thanks!
Attached File(s)
Attached File  solution.bmp ( 615.45K ) Number of downloads: 6
 
Go to the top of the page
 
+
theDBguy
post Dec 8 2011, 12:19 PM
Post #6

Access Wiki and Forums Moderator
Posts: 48,058
From: SoCal, USA



Hi Bill,

Congratulations!

Good luck with your project.
Go to the top of the page
 
+

Thank you for your support! Reply to this topicStart new topic

Jump To Forum:
 



RSS Go to Top  ·  Lo-Fi Version Time is now: 23rd May 2013 - 06:05 PM