Ignore error and resume

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.
 
F

fredg

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!
 
J

Jesse

In code, before you do the output, check the recordcount property. If
it is less than 1 the code should exit.
 
S

Steve Schapel

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.
 
B

BruceM

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top