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

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
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"
?
 
Upvote 0
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 !!
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,214,641
Messages
6,120,693
Members
448,979
Latest member
DET4492

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
Back
Top