Native Access error

MLT

Registered User.
Local time
Today, 06:12
Joined
Nov 14, 2002
Messages
12
Native Access error on DELETE statement

For some crazy reason, I thought it would be easier to design this app using Access instead of from scratch usinng VB.

I am using the following code to delete records from a subform:
DoCmd.RunSQL strSQLBreakDown . The variable is an SQL delete statement.

I have written some code that returns dialog boxes to make sure the user wants to continue but Access automatically returns the following error:

You are about to delete x row(s) from the specified table. Once you click yes, you can't use Undo command to reverse the changes. Are you sure you want to delete the selected records?

The error can only be resolved the vb yes or no buttons. If the user chooses No, Access returns another error resolved by vbOKonly that prompts The RunSQL action was cancelled. Is there a better way to design this?

TIA
ML
 
Last edited:
ML,

You can turn off warnings to avoid the system messages.

DoCmd.SetWarnings False
DoCmd.RunSQL "strSQLBreakDown"
DoCmd.SetWarnings True

Regards,
Tim
 
Fixed used CurrentDB.execute

Thanks Tim. I also found another option that works too. As an alternative, I tried using:
CurrentDB.Execute strSQLBreakdown
and it worked without throwing any Access errors. Your advice will come in handy though. I didn't know about that method.

Thanks again,
ML
 
ML,

CurrentDB.Execute -- that's good to know. And it's only one line. Thanks back.

Tim
 

Users who are viewing this thread

Back
Top Bottom