A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Error Handling Where? When?



 
 
Thread Tools Display Modes
  #1  
Old April 18th, 2010, 11:13 PM posted to microsoft.public.access
PeterM
external usenet poster
 
Posts: 208
Default Error Handling Where? When?

I'm now at the stage that I need to build in some error handling in my
database. The question I have is say for example, I have a field that is
required on a form. I have a Save button attached to the form.

Should I check for the required field when the required field looses focus?
or in the Before Update procedure? or in the Form_Save event?

I tend to write a procedure that will scan the entire form and display a
generic form listing all errors and warnings at once instead of doing one at
a time. It that unnecessarily complicating the process?

Thanks for your advice!
  #2  
Old April 19th, 2010, 12:00 AM posted to microsoft.public.access
John W. Vinson
external usenet poster
 
Posts: 18,261
Default Error Handling Where? When?

On Sun, 18 Apr 2010 15:13:01 -0700, PeterM
wrote:

I'm now at the stage that I need to build in some error handling in my
database. The question I have is say for example, I have a field that is
required on a form. I have a Save button attached to the form.

Should I check for the required field when the required field looses focus?
or in the Before Update procedure? or in the Form_Save event?


The BeforeUpdate event fires right before the record is written to disk (that
is when you need it), and it can be cancelled (unlike the LostFocus event) so
it's the best place for this.

I tend to write a procedure that will scan the entire form and display a
generic form listing all errors and warnings at once instead of doing one at
a time. It that unnecessarily complicating the process?


It's up to you: Access won't care but your users may thank you (for getting
nagged once with three warnings rather than three times in succession). It's
certainly more work but I'd be inclined to do it if you're up to it.
--

John W. Vinson [MVP]
  #3  
Old April 19th, 2010, 05:11 AM posted to microsoft.public.access
PeterM
external usenet poster
 
Posts: 208
Default Error Handling Where? When?

Oh! I'm up to it. As a matter of fact I just finalized the error processing
for my system. I now edit the form for data errors. As errors are found I
call a subroutine to insert a row into an errorswarnings table with the error
information (controlname, formname, errordesc, etc). In the beforeupdate
procedure I query the errorswarnings table and if found, I open a generic
form displaying the error information. I've also added functionality to
allow the users to leave the error form open (popup=yes, modal = no) so they
can change the form based on the errors listed. After making corrections and
press the save button, I call the routine again and update the error form.
If everything is OK the errors/warnings form is closed and the record is
saved.

I've showed one of my end users and they are thrilled that all
errors/warnings are displayed at once and they really liked the ability to
change the data entry form while the errors/warnings are displayed and then
resubmit the save once they correct all errors.

Thanks to everyone for their ideas!

Pete

"John W. Vinson" wrote:

On Sun, 18 Apr 2010 15:13:01 -0700, PeterM
wrote:

I'm now at the stage that I need to build in some error handling in my
database. The question I have is say for example, I have a field that is
required on a form. I have a Save button attached to the form.

Should I check for the required field when the required field looses focus?
or in the Before Update procedure? or in the Form_Save event?


The BeforeUpdate event fires right before the record is written to disk (that
is when you need it), and it can be cancelled (unlike the LostFocus event) so
it's the best place for this.

I tend to write a procedure that will scan the entire form and display a
generic form listing all errors and warnings at once instead of doing one at
a time. It that unnecessarily complicating the process?


It's up to you: Access won't care but your users may thank you (for getting
nagged once with three warnings rather than three times in succession). It's
certainly more work but I'd be inclined to do it if you're up to it.
--

John W. Vinson [MVP]
.

  #4  
Old April 20th, 2010, 12:06 AM posted to microsoft.public.access
John W. Vinson
external usenet poster
 
Posts: 18,261
Default Error Handling Where? When?

On Sun, 18 Apr 2010 21:11:01 -0700, PeterM
wrote:

Oh! I'm up to it. As a matter of fact I just finalized the error processing
for my system. I now edit the form for data errors. As errors are found I
call a subroutine to insert a row into an errorswarnings table with the error
information (controlname, formname, errordesc, etc). In the beforeupdate
procedure I query the errorswarnings table and if found, I open a generic
form displaying the error information. I've also added functionality to
allow the users to leave the error form open (popup=yes, modal = no) so they
can change the form based on the errors listed. After making corrections and
press the save button, I call the routine again and update the error form.
If everything is OK the errors/warnings form is closed and the record is
saved.

I've showed one of my end users and they are thrilled that all
errors/warnings are displayed at once and they really liked the ability to
change the data entry form while the errors/warnings are displayed and then
resubmit the save once they correct all errors.


Sounds impressive, Pete! If it's sufficiantly general, would you consider
posting it to one of the Access sites so others can use it?
--

John W. Vinson [MVP]
  #5  
Old April 21st, 2010, 05:19 AM posted to microsoft.public.access
Tony Toews [MVP]
external usenet poster
 
Posts: 3,776
Default Error Handling Where? When?

PeterM wrote:

Oh! I'm up to it. As a matter of fact I just finalized the error processing
for my system. I now edit the form for data errors. As errors are found I
call a subroutine to insert a row into an errorswarnings table with the error
information (controlname, formname, errordesc, etc). In the beforeupdate
procedure I query the errorswarnings table and if found, I open a generic
form displaying the error information. I've also added functionality to
allow the users to leave the error form open (popup=yes, modal = no) so they
can change the form based on the errors listed. After making corrections and
press the save button, I call the routine again and update the error form.
If everything is OK the errors/warnings form is closed and the record is
saved.


Or you could use a listbox on the bottom of the main form. You could
manually add items using listbox.additem thus saving the need for a
separate form and table.

Tony
--
Tony Toews, Microsoft Access MVP
Tony's Main MS Access pages - http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
For a convenient utility to keep your users FEs and other files
updated see http://www.autofeupdater.com/
Granite Fleet Manager http://www.granitefleet.com/
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 06:21 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.