473,561 Members | 3,772 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 7849
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,564 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,564 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,564 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,564 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
4042
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
5023
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
3082
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
3885
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...
14
8068
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...
8
2778
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
3843
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",...
3
3800
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
4131
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...
3
3519
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...
0
7558
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...
0
7851
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. ...
0
8072
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...
0
7924
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5177
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...
0
3609
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...
0
3591
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2055
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
1
1171
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.