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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to trap the Database Error and substitute it with the Mesgbox

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hello.<br><br>When the forms are closed the access tryes to save the unsaved records entered, but if some fileds left null it will give an ODBC error. I would like to know if anyone konws how trapt the error and on wich even should I place the the undo command or some sort of MsgBox which would ask user to either complete the record entered or undo the last action and exit the application.&nbsp;&nbsp;I would appreciate if you can help me.<br><br>Regards.
 
try the before_update event of the form, or the OnError event also. <p>Mohamed Aly<br><a href=mailto:samara_79@hotmail.com>samara_79@hotmail.com</a><br><a href= > </a><br>
 
Thanks <br>I tried both but the the error is raised by the MSSQL server.&nbsp;&nbsp;MS Access Forms I have developed has been based on the MSSQL linked tables.&nbsp;&nbsp;The errors are ODBC connection failed and cannot insert null value.&nbsp;&nbsp;<br>&nbsp;&nbsp;The mesages which I put are dispalyed but the the system errors continue to appear afterwards befor the form is closed and I am afraid it can be confusing for the back end user.&nbsp;&nbsp;If you have delt with similar problem Can you give me more specific way to trap the error and sbustitue it with the meseage I want the user to see.<br><br>Ragards
 
There is a FAQ on this. I don't know if there is something special or different about an ODBC error, but this works for other error types. Go to the Access: General discussuib forum at this site, click on the FAQ tab at the top of the page, and look at: <br><br>&quot;VBA and Custom Functions&quot; category,<br>&quot;.Basic Error handling - hide an Access error message or substitute your own&quot;<br><br>If this doesn't work, please post yur problem/solution here, we can then incorporate it into the FAQ.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top