acSaveRecord issue and required fields

  • Thread starter joyd via AccessMonster.com
  • Start date
J

joyd via AccessMonster.com

i have a button for exporting a single record into a report and e-mail... the
problem is that when the record needs to be saved first, but i don't want
this to be allowed without all the required fields filled in. acSaveRecord
produces an error if not all fields are filled in, sending you to the
debugger. i have created a macro from the standard save button and have it
run before the rest of my code, but when doing so, i get the "required field"
error message from the macro, but the code continues to run, creating the e-
mail, even though not all required fields are filed. does anyone have a
solution?

Thanking you in advance,

thanos
 
A

Allen Browne

If you are using Access 2007, it is possible to use error handling in
macros, but the simplest solution in any version is to use VBA code.

You declare an error handler at the top of your code. When an error occurs
(e.g. required field not filled in), it drops to the error handler, and so
the rest of the code doesn't exeucte.

Here's an example of error handling in VBA code:
http://allenbrowne.com/ser-23a.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top