Error Handling Best Practice

MCCDOM

Registered User.
Local time
Today, 06:37
Joined
Oct 30, 2014
Messages
84
Hi All,

I am trying to implement error trapping to prevent errors or incorrect data from being entered.
The way I have it setup currently is a lot of 'If' statements for individual comboboxes to check if the combobox is a 'Null' value and if so to show an error message "Please select a value".
This is very messy and, from what I've heard, hard to debug.

What would be a good method to check all three comboboxes for a value upon a button click and present the user with a message if a 'Null' value is found?

Many thanks for your help,

Dom
 
An array, a loop and a blank string. Put the control names into an array, loop through all the controls and see if any are null. When found, you add the name to the string. After the loop if the string has a length>0, you msgbox out a message which shows all null fields.

Bonus points for doing it without the blank string--hint-- remove the value from the array if its control is null.
 
For 3 combo boxes, IMO hardly worth the effort of doing anything other than writing 4 lines of code in the update event of one combo, and then copy/paste with small mod for the others. Probably do in less time than it took to write this.

Or did I miss something?
 
Consider changing your use of terminology. This is not about "Error Handling" which has a very specific meaning in the context of coding.

What you are addressing is called "Validation".
 
Thank you plog and Cronk for your suggestions. I will see which one works best in my situation.
Galaxiom you're quite right and I will remember for next time.
 

Users who are viewing this thread

Back
Top Bottom