473,698 Members | 2,051 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Delete Records from a Form

145 New Member
Split off from To search record.
No worries :)

Let us know how this works for you.
It works well..Another question is I want to delete records from a form when I try to delete from the form, the records do not delete in the table. Why do this happen? I use the access button wizards.

The form name is [Delete Record]. The control are

textbox: [txtISBN],
button: cmdDelete,

where user enter the ISBN/ISSN number and click delete, the records will be deleted.
Oct 10 '08 #1
8 7862
puT3
145 New Member
I used this code
Expand|Select|Wrap|Line Numbers
  1. Dim strMsg As String
  2.     Dim strSQL As String
  3.  
  4.     strMsg = "Are you sure you want to delete this record? You cannot undo a deletion."
  5.  
  6.     If MsgBox(strMsg, vbYesNo) = vbYes Then
  7.         strSQL = "DELETE * FROM [Printing Media Library] WHERE [Printing Media Library].[ISBN/ISSN]= " & [Forms]![View/Delete Record]![txtISBN] & ";"
  8.     CurrentDb.Execute strSQL, dbFailOnError
  9.     DoCmd.GoToRecord , , acNewRec
  10. Else
  11.     DoCmd.OpenForm "Delete Record"
  12. End If
and there is error saying "data type mismatch in criteria expression"
Oct 10 '08 #2
puT3
145 New Member
and I want to know how to disable the design,view,lay out view,so that user cannot change it....
Oct 10 '08 #3
NeoPa
32,569 Recognized Expert Moderator MVP
and I want to know how to disable the design,view,lay out view,so that user cannot change it....
Are you talking about the Form property Allow Design Changes? This should be set to Design View Only.
Oct 10 '08 #4
NeoPa
32,569 Recognized Expert Moderator MVP
I used this code
Expand|Select|Wrap|Line Numbers
  1. Dim strMsg As String
  2.     Dim strSQL As String
  3.  
  4.     strMsg = "Are you sure you want to delete this record? You cannot undo a deletion."
  5.  
  6.     If MsgBox(strMsg, vbYesNo) = vbYes Then
  7.         strSQL = "DELETE * FROM [Printing Media Library] WHERE [Printing Media Library].[ISBN/ISSN]= " & [Forms]![View/Delete Record]![txtISBN] & ";"
  8.     CurrentDb.Execute strSQL, dbFailOnError
  9.     DoCmd.GoToRecord , , acNewRec
  10. Else
  11.     DoCmd.OpenForm "Delete Record"
  12. End If
and there is error saying "data type mismatch in criteria expression"
I expect [ISBN/ISSN] is a string/text field. In which case the format of your SQL is wrong. Try this for line #7 instead :
Expand|Select|Wrap|Line Numbers
  1. strSQL = "DELETE * " & _
  2.          "FROM [Printing Media Library] " & _
  3.          "WHERE [ISBN/ISSN]='" & [Forms]![View/Delete Record]![txtISBN] & "'"
Oct 10 '08 #5
puT3
145 New Member
I expect [ISBN/ISSN] is a string/text field. In which case the format of your SQL is wrong. Try this for line #7 instead :
Expand|Select|Wrap|Line Numbers
  1. strSQL = "DELETE * " & _
  2.          "FROM [Printing Media Library] " & _
  3.          "WHERE [ISBN/ISSN]='" & [Forms]![View/Delete Record]![txtISBN] & "'"
Thank you, it works now...thanks a lot
Oct 11 '08 #6
NeoPa
32,569 Recognized Expert Moderator MVP
Excellent. That's two threads sorted in a week (or so) :D

Sounds like progress ;)
Oct 11 '08 #7
puT3
145 New Member
How can I make the report do not show any empty records? For example, in this [Company] table do not has address...I want the report only shows company that has address
Oct 19 '08 #8
NeoPa
32,569 Recognized Expert Moderator MVP
OK. But do me a favour.

Post this question in it's own thread with all the required details (searching through the previous thread to remind myself of everything leaves me dooing all the work here. That's not the right balance).

Feel free to post a link in here to your new thread and I will certainly have a look and help. This should be a simple question, but without the facts to hand, it is far more complicated than it needs to be.
Oct 19 '08 #9

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

Similar topics

8
4062
by: Steve | last post by:
I have several pairs of synchronized subforms in an application. I have a Delete button for each pair that uses the following code or similar to delete a record in the second subform: DoCmd.SetWarnings False DoCmd.RunCommand acCmdDeleteRecord DoCmd.SetWarnings True End If ExitHere: Me!SubName.SetFocus
5
5034
by: hpi | last post by:
Hello, I have a table : Batch It contains fields batchnummer : Number (Long Integer) datum : Date/Time status : Number (Long Integer) nr_records : Number (Long Integer)
6
3100
by: Paul T. Rong | last post by:
Dear all, Here is my problem: There is a table "products" in my access database, since some of the products are out of date and stopped manufacture, I would like to delete those PRODUCTS from the table, but I was not allowed to do that, because "there are records related with those PRODUCTS in other tables (e.g. in table "ORDER_DETAIL").
3
3899
by: Tim Marshall | last post by:
HI all, Access 2003, Jet back end. Rather than annoy my users in a particular app by having relationships with enforced relational integrity refuse to delete a record with related records, I'm using cascade delete. When I use a continuous form and a record is deleted, Access provides a warning that there are related records, do you want to continue (an aside - anyone know how to trap that warning on the form on error event?). However,...
14
8077
by: Darin | last post by:
I have a table that I want to delete specific records from based on data in other tables. I'm more familiar with Access '97, but am now using 2003, but the database is in 2000 format. In '97, I think I could have easily done this using joins, but I kept getting "could not delete from specified tables" errors. Some google searching has indicated I need to use a subquery. After many failed attempts with different approaches, I finally...
8
2779
by: paulwilliamsonremove | last post by:
Hi, Using Access 2003. I am trying to delete records from one table/query ("qryHistoryPersonIDs") if they don't exist in another table ("qryDonations"). But the SQL syntax I came up with is taking forever or locking up Access 2003. What am I doing wrong?
6
3854
by: polocar | last post by:
Hi, I'm writing a program in Visual C# 2005 Professional Edition. This program connects to a SQL Server 2005 database called "Generations" (in which there is only one table, called "Generations"), and it allows the user to add, edit and delete the various records of the table. "Generations" table has the following fields: "IDPerson", NamePerson", "AgePerson" and "IDParent". A record contains the information about a person (his name, his...
3
3806
by: Kevin M | last post by:
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
5
4139
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
3527
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
9016
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
8887
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7709
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6515
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
4360
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...
0
4613
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3037
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2321
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1997
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.