473,405 Members | 2,404 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Deleteing selected records with a button

Hi all,

I'm trying to allow the user to search through records and using a checkbox, allow the user to select one or multiple records, then click a button and delete all that were selected. I'm thinking I should include some code that will delete all records that have the [deleterecord]=1. I know how to create buttons and use events, I'm just not sure on what the code should look like. I'm using Access 2003. Thanks for all your help!
Jul 11 '07 #1
5 3444
missinglinq
3,532 Expert 2GB
Datasheet, Continuous Form or Single View Form? You should always include this info when posting questions involving forms; it can make a world of difference in our answers!

Linq ;0)>
Jul 11 '07 #2
Datasheet, Continuous Form or Single View Form? You should always include this info when posting questions involving forms; it can make a world of difference in our answers!

Linq ;0)>
Sorry! It is a datasheet that is a subform in a single view form. I have the delete button on the single view form. Also, I already have the checkboxes in the datasheet subform, It is the task of deleted the ones that are selected that I am stuck on. Thanks again!
Jul 11 '07 #3
missinglinq
3,532 Expert 2GB
One way is to run a SQL statement to delete the records from the table the subform is based on, then Requery your subform.



Expand|Select|Wrap|Line Numbers
  1. Private Sub DeleteMultiRecords_Click()
  2. Dim strQuery
  3. strQuery = "DELETE * FROM YourTableName WHERE YourCheckBoxName" 'Define SQL statement
  4. DoCmd.RunSQL (strQuery)  ' Run SQL
  5. Me.YourSubformName.Requery  'Requiry to records go "poof!
  6. End Sub
Good Luck!

Linq ;0)>
Jul 11 '07 #4
Linq,

Thanks for your help. The code worked great and helped me get over a hurdle. Thanks again!
Jul 11 '07 #5
missinglinq
3,532 Expert 2GB
That's why we're here! Glad we could help!

Linq ;0)>
Jul 11 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: DC Gringo | last post by:
I'm having such a problem with this DropDownList in a user control that is posting back and throwing an error: System.Web.HttpException: A DropDownList cannot have multiple items selected ...
2
by: Support4John | last post by:
a2k (9.0.6926) SP-3 Jet 4.0 SP-7 I have a button on a Single Form that when pressed displays all the underlying records in the table in a Datasheet Form. For example, Northwind, Customer...
2
by: David | last post by:
Hi, I have an order form which has a field 'ProductID'. This form has a button on each record to open a new form linked by ProductID. This new form is a continuous form and obviously, only...
4
by: acni | last post by:
I have the following peice of code to try and send an email to selected contacts in my form.The problem is this line: StrStore = DLookup("", "qrySelectEmail", "??????") This looks up the email...
5
by: Mojtaba Faridzad | last post by:
Hi, with SetDataBinding( ) a DataGrid shows a DataView. user can select some rows in the grid by holding cotrol key. when user clicks on Delete button, I should delete all selected rows. I am...
5
by: BBFrost | last post by:
Win2000 ..Net 1.1 SP1 c# using Visual Studio Ok, I'm currently in a "knock down - drag out" tussle with the .Net 1.1 datagrid. I've come to realize that a 'block' of rows highlighted within...
5
by: Dick | last post by:
I have a GridView bound to an ObjectDataSource. I have a Button that calls GridView.DataBind. I want the row that is selected before the DataBind to still be selected afterwards. This happens...
4
by: rn5a | last post by:
I am binding a DropDownList with records existing in a database table. I want to add an extra item *SELECT COMPANY* at index 0 so that by default, it gets selected. This is how I tried it but the...
2
by: kurtzky | last post by:
i created a form that should function as follows: i will enter a number in a textbox..then it should query from the database all the records which has that number..these records will have a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.