Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

working with selected records in a datasheet

Status
Not open for further replies.

abenitez77

IS-IT--Management
Oct 18, 2007
147
US
I have a SQL view linked into a ms access application. That view is used in a subform and in datasheet view. I want to select multiple records and click on a button that will delete those selected rows. I need the button because the view has 1 table and a subquery joined in the view and will not allow me to delete from the main table in that view. So, I figured I can select the rows I want to delete and then create a button that will send a passthru command to delete those records from the main table. Can you help?
 
What I think you are trying to do is display data from multiple tables and delete the selected records from one table...

If you link a View into Access as a table and used the Access Linked table, you can do anything that the Access User Interface can do so long as the view is updatable... If this is the case, you should be able to select the records and simply press the delete key but you might get more than just one table that way.

You can create code to delete one or more records in a table but you'd need something like a list of key values... In your scenario I'm thinking you'd get the list from a multi-select list box. There are lots of examples floating around and I have rarely used it so I can't quickly give an example.

Then you'd either use an ADO command object or SQL Pass through Query (whose SQL property you'd set using DAO) to execute SQL code to delete records with a where clause using in and the value list...

Besides tables and views another thing you might find of interest in SQL Books On Line is "In-line User Defined Function", back when I played with an ADP someone told me those are updateable which I needed as you can pass parameters to it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top