You can use...
On error resume next
BUT I typically don't advise this. If you use it, make sure to put something like this at the end of the coding...
On error goto Done
On error goto 0
(I personally prefer the On Error goto Done versus On error goto 0)
Using the On error resume next can be VERY dangerous as it will eliminate any errors from showing which you don't really want to do unless absolutely needed (or until the mdb is closed and reopened). Again, if you use it, make sure to put in something as that above to re-instate error checking and make sure your code 'hits' that line of re-instating error checking. I rarely use the on error resume next due to it's dangerous potential.
Typically, instead of the On error resume next, I'll put in On error goto SomeLabel and make it so that SomeLabel is where I want it to go.
On error goto BadData
msgbox "Bad data was entered....."
Another option when updating queries and you don't want it to show a popup saying "you are about to update x records...", you can use the docmd.setwarnings false
Again, importantly making sure to turn the warnings back on.
I usually do something like this when it comes to update type queries.
Dim QI as integer
QI = msgbox("Are you sure you want to update the recordset? (this is your last warning before updating the data)",vbYesNo+vbExclamation)
if QI = vbno then exit sub
Just remember that the most important thing is if the code fails, you want it to go to some part of the coding which re-instates error checking again.
For example, this could be bad:
some other coding...
because if something fails in the other coding and it never hits the docmd.setwarnings true line of coding, you've then turned off warnings messages.
Last edited by pkstormy; 04-28-10 at 11:14.
Expert Database Programming
MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)