DELETE record using code

dspa0712

New Member
Joined
May 4, 2007
Messages
31
I have a procedure written to load up data from several Excel workbooks in an Access Table called "data".

I have had a blank moment and was wondering whether someone could help me out: :oops:

At the end of the code I want to include a line to execute in order to delete all occurances from the table "data" where a field called "Provider" is blank.

Please help !!!!
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.

tom_crisp

Board Regular
Joined
Jul 28, 2006
Messages
133
Don't know about this in pure VBA, but could you not create a delete query with the required criteria, and have VBA run this using
Code:
docmd.openquery "yourquery"
?
 

dspa0712

New Member
Joined
May 4, 2007
Messages
31
I could Tom but ideally I want the process to run through VB Code as to quicken it up and not burden the dbase down with more queries than needed.

thanks anyway !!
 

smozgur

BatCoder
Joined
Feb 28, 2002
Messages
1,981
You can use Execute method of CurrentDb object:

CurrentDb.Execute("DELETE * FROM data WHERE Provider is Null")

You can change your SQL statement as you like, Provider = '' or something else.

Please note it will directly delete your data without any confirmation, even related data without a notice.

Suat
 

Forum statistics

Threads
1,181,649
Messages
5,931,216
Members
436,784
Latest member
amuljono

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top