troubleshooting Question

Delete selected records with a button in Datasheet view

Avatar of holgrave
holgraveFlag for United Kingdom of Great Britain and Northern Ireland asked on
Microsoft Access
7 Comments1 Solution873 ViewsLast Modified:
I have a form called frmProducts with a subform on it called subProducts.

The subform is in datasheet view.

I have a 'Delete' button on my form which when pressed I want the SELECTED records in the subform deleted.

The subform has it's RecordSelectors visible - this is how the user can select mutliple records.

In the button click event I have:

 subProducts.SetFocus
 DoCmd.RunCommand acCmdDeleteRows


The problem is that as soon as the user Clicks the 'Delete' button the focus moves from the subform which causes the selection of records in the subform to change. The selection changes to become only the current record.

Is there a way to stop this behaviour?

Currently the only way the user can delete a range of records is by right mouse clicking on the selection to bring up the 'context sensitive' menu (also know as pop-up menu) and selecting delete from here. Obviously such menus do not cause a change of focus to occur.

The use of context sensitive menus is far from intuitive for most users however - so this is far from idea as a solution.

Just clicking a button is much better.

ASKER CERTIFIED SOLUTION
nico5038

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 7 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros