Delete statement in Access

Status
Not open for further replies.

coxmd410

New Member
Joined
Nov 20, 2012
Messages
14
I have an Access database that has one table containing employee information. I have created Forms for easy user-interface. I am having problems with one of my forms.

When looking at my main menu (a form) you see employee names. You can select a name and click an "edit/delete" button that opens a pop-up form showing all the information for that employee.

I have a button on that pop-up form to delete the employee you are viewing. The problem is my code is deleting all records in the table, not just the record being viewed.

Here is my code:

Private Sub deleteRecords_Click()

Dim db as Database
Set db = CurrentDb
db.Execute "Delete * From employees;"

End Sub

Also, could someone please explain what Dim db and Set db do? I just copied them from online? Thanks!</SPAN>
 

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
Status
Not open for further replies.

Forum statistics

Threads
1,207,277
Messages
6,077,488
Members
446,286
Latest member
ropebender

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