Ignore error and resume

  • Thread starter Thread starter wesley.allen
  • Start date Start date
W

wesley.allen

Hello,

Hope you are doing well.


I have code written that outputs a table and then opens the table that
was output, selects all records, and deletes the records. The problem
is, if there are no records in the table, the code errors and stops.
Is there script I can add that will ignore the error and resume the
code?


Thanks.
 
Hello,

Hope you are doing well.

I have code written that outputs a table and then opens the table that
was output, selects all records, and deletes the records. The problem
is, if there are no records in the table, the code errors and stops.
Is there script I can add that will ignore the error and resume the
code?

Thanks.

Wouldn't it have been much simpler to see your code so that we
wouldn't have to guess at what your current error handling is (you do
have error handling don't you?).
Post your code!
 
In code, before you do the output, check the recordcount property. If
it is less than 1 the code should exit.
 
Wesley,

I agree with Fred that more specific details would be helpful.

But anyway, if you literally mean that your code opens a table
datasheet, selects the records, and deletes them, then this is probably
an unnecessarily awkward approach. You could use a Delete Query. Your
code could simply be like this...
CurrentDb.Execute "DELETE FROM YourTable", dbFailOnError
As far as I know, this will still proceed fine even if there are no
records in the table.
 
This is the same question you posted in the formcoding group. Post the same
message to multiple groups if you must (although it is rarely necessary),
but posting separate, identical messages to several groups is considered
poor newsgroup etiquette. Somebody may be answering in one group, now
knowing that you have received the reply in the other group. That is a
waste of volunteered time.
 
Back
Top