Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trapping Errors

Status
Not open for further replies.

HiBoo

Programmer
Jan 11, 2000
88
CA
Hi everyone, I've got a problem with trapping errors... problem being I don't know how!!!<br><br>What I want to do is bypass ACCESS default messages and display my own, more descriptive messages when the user enters invalid data.<br><br>For example, I've got a txt field that is to contain curreny data.&nbsp;&nbsp;I've set the format to 'Currency' and I've got my own error checking procedure coded in Afterupdate.&nbsp;&nbsp;How do I bypass the default error handler and go straight to my own code???<br>
 
<i>You'll most likely want to use the Form_Error Event. I did'nt include the exact error code, I don't know it. Use the value returned in 'err.number' while tracing through the code to get the value for this specific error, then just test for it in the&nbsp;&nbsp;Form_Error Event.</i><br><br><br>Private Sub <b>Form_Error(DataErr As Integer, Response As Integer)</b><br>ConstantValueForInvalidData = ? 'you'll have to look this up.<br><br>If DataErr = ConstantValueForInvalidData Then<br>&nbsp;&nbsp;MsgBox &quot;Enter valid currency value, O.K. ?!!&quot;, vbExclamation<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CurrencyDataTextField.SetFocus<br><b>Response = acDataErrContinue</b> '<font color=red>cancel the Access Error Dialog</font><br> End If<br>End Sub<br><br>If this is the only text box on the form that could generate this error then the above is sufficent. If there are more than one then you'll have to determine which text box generated the error and thus set the focus to the correct box.<br> <p>Amiel<br><a href=mailto:amielzz@netscape.net>amielzz@netscape.net</a><br><a href= > </a><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top