473,721 Members | 1,930 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Delete Query

I have one table and have created a form from that table. Also, I have
created a delete query. I want to but a button on the form which will delete
all records from the table; however, I cannot get anything to work. I know
this is probably simple for more experienced Access users. Any help would be
greatly appreciated.

Thanks
Kevin


Dec 5 '06 #1
3 3810
On Tue, 5 Dec 2006 17:14:34 -0500, Kevin M wrote:
I have one table and have created a form from that table. Also, I have
created a delete query. I want to but a button on the form which will delete
all records from the table; however, I cannot get anything to work. I know
this is probably simple for more experienced Access users. Any help would be
greatly appreciated.

Thanks
Kevin
"Cannot get anything to work" doesn't give us any useful information.
What exactly is the SQL of your delete query?
Does that work by itself?

If so, then code the command button click event:

CurrentDb.Execu te "DeleteQueryNam e",dbFailOnErro r

If the query doesn't work by itself, post the query SQL.
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
Dec 5 '06 #2

"fredg" <fg******@examp le.invalidwrote in message
news:11******** *************** *******@40tude. net...
On Tue, 5 Dec 2006 17:14:34 -0500, Kevin M wrote:
>I have one table and have created a form from that table. Also, I have
created a delete query. I want to but a button on the form which will
delete
all records from the table; however, I cannot get anything to work. I
know
this is probably simple for more experienced Access users. Any help would
be
greatly appreciated.

Thanks
Kevin

"Cannot get anything to work" doesn't give us any useful information.
What exactly is the SQL of your delete query?
Does that work by itself?

If so, then code the command button click event:

CurrentDb.Execu te "DeleteQueryNam e",dbFailOnErro r

If the query doesn't work by itself, post the query SQL.
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
Sorry, I don't know what the SQL is? As far as caanot get anything to work,
I tried several differenct code variations I've fond and none of them work.
I can run the delete query and it does work. I would like to be able to be a
button on the form that does the same thing. When I add a button, and choose
"run query", the delete query does not show up as a choice. Hope this makes
sense.

Thanks
Dec 6 '06 #3
On Wed, 6 Dec 2006 08:41:30 -0500, Kevin M wrote:
"fredg" <fg******@examp le.invalidwrote in message
news:11******** *************** *******@40tude. net...
>On Tue, 5 Dec 2006 17:14:34 -0500, Kevin M wrote:
>>I have one table and have created a form from that table. Also, I have
created a delete query. I want to but a button on the form which will
delete
all records from the table; however, I cannot get anything to work. I
know
this is probably simple for more experienced Access users. Any help would
be
greatly appreciated.

Thanks
Kevin

"Cannot get anything to work" doesn't give us any useful information.
What exactly is the SQL of your delete query?
Does that work by itself?

If so, then code the command button click event:

CurrentDb.Exec ute "DeleteQueryNam e",dbFailOnErro r

If the query doesn't work by itself, post the query SQL.
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail

Sorry, I don't know what the SQL is? As far as caanot get anything to work,
I tried several differenct code variations I've fond and none of them work.
I can run the delete query and it does work. I would like to be able to be a
button on the form that does the same thing. When I add a button, and choose
"run query", the delete query does not show up as a choice. Hope this makes
sense.

Thanks
OK, so the query by itself works.

The command button wizard, unfortunately, does not include Delete
queries choices.

1) I gave you one answer in my previous reply.
After you add the command button (you don't need the wizard for this),
open the command button property sheet. Click on the Event tab.
Click on the Click event line and write:
[Event Procedure]
Then click on the little button with the 3 dots that appears on that
line.
The code window will open with the cursor flashing between 2 already
existing lines of code.
Between those 2 lines write:

CurrentDb.Execu te "DeleteQueryNam e",dbFailOnErro r

Change "DeleteQueryNam e" to whatever the actual name of the delete
query is.
Close the code window and you are done.

2) Alternatively, if you do use the wizard when adding the command
button, select ANY query from the available list.
Then open the command button's property sheet and click on the 3 dot
button on the click event line.
When the code window opens, the existing code will be something like:

Private Sub Command553_Clic k()
On Error GoTo Err_Command553_ Click

Dim stDocName As String

stDocName = "AQueryName "
DoCmd.OpenQuery stDocName, acNormal, acEdit

Exit_Command553 _Click:
Exit Sub

Err_Command553_ Click:
MsgBox Err.Description
Resume Exit_Command553 _Click

End Sub

Change
stDocName = "AQueryName "

to whatever the Delete query name is.

Save the changes.

The 1st method (.Execute) will run the query without giving a warning
message, but will give a message if the delete query fails.

The 2nd method (OpenQuery) will give a warning message that "You are
about to delete ...etc" records, and gives you the opportunity to exit
without deleting records. If you do not wish to get the warning
message, then add 2 lines of code as indicated below:

DoCmd.SetWarnin gs False
DoCmd.OpenQuery stDocName, acNormal, acEdit
DoCmd.SetWarnin gs True

I hope this helps.
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
Dec 6 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
8899
by: Andrew DeFaria | last post by:
I created the following .sql file to demonstrate a problem I'm having. According to the manual: If |ON DELETE CASCADE| is specified, and a row in the parent table is deleted, then InnoDB automatically deletes also all those rows in the child table whose foreign key values are equal to the referenced key value in the parent row. However:
2
11200
by: Joe Del Medico | last post by:
I have two tables A & B and I want to delete all the records in A that are not in B. Can I do this in the query builder? It seems like a simple problem. I can easily find the records in A that aren't in B by using the query wizard to come up with a query "A without matching B". I added table A to the query builder and Query "A without matching B" joined them with the index field (Loan Number) made the query a delete query and
5
1792
by: ms | last post by:
Why does this select query return the correct records but when I make it a delete query I get a msgbox with "Could not delete from specified tables". SELECT BMIDLog.* FROM stageBMIDLog INNER JOIN BMIDLog ON (BMIDLog.BattID = stageBMIDLog.BattID) AND (BMIDLog.VehicleID = stageBMIDLog.VehicleID) AND (BMIDLog.TotalChgAhs = stageBMIDLog.TotalChgAhs) DELETE BMIDLog.*
2
2580
by: Dave Burt | last post by:
Hi, Access officionados, I'm new here, so please cut me slack/gently tell me off if I'm out of line or in the wrong place. OK, here's something that seems silly (and is also problematic to me). I have a query which is updateable when viewed as a datasheet in Access (you can insert, delete, update). Using queries, I can insert and update, but not delete.
8
25070
by: John Baker | last post by:
Hi: Access 2000 W98! I have a table with numerous records in it, and am attempting to delete certain records that have been selected from it. These are selected based on the ID number in a different table. While I am using the tools in Access for query setup, its easier to show it on here using the SQL for the query, which is as follows( the table is ): DELETE .date, .,
13
2861
by: forbes | last post by:
Hi, I have a user that used the Query Wizard to create a query in Access. Now she claims that her master table is missing all the data that was excluded from the query. Can you create anything other than a select query using the Wizard? What do you think happened to her data? I am working remotely until Friday, so I can't get down to her office and check out what she did.
1
3621
by: Matt | last post by:
I am writing a DELETE statement and I want to filter the records using another SELECT statement. My SELECT statement is a GROUP BY query that grabs all social security numbers from the "Data With Import Date Current" table on a given day where there was only one transaction (count of SSN = 1). I want to delete these records from the "Data With Import Date Current" table. I would like to do this by joining the "Data With Import Date...
5
4143
by: Bob Bridges | last post by:
Start with two tables, parent records in one and child records in the other, a one-to-many relationship. Create a select statement joining the two. Display the query in datasheet mode. When I delete a row, only the child record is deleted from the source tables; the parent record is still there...which is what I wanted. Now display fields from that query in a continuous form. When I delete a record from that form, one of the child...
3
3529
by: Phil Stanton | last post by:
I have a form based on a complex query (Lots of tables) If I delete a record, everything appears to be OK. Get the message "Youa are about to delete 1 record ....". I say yes. The record count goes down correctly. Then if I do Records-->Remove Filter/Sort there are the deleted records back as if they had never been deleted. Same thin exactly if I do the operation on the form's recordsource query, so that eliminates anything to do with...
0
8840
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8730
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9367
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9215
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
6669
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5981
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4484
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2576
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2130
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.