Queries :: Delete All After First Cancelled Record
Aug 20, 2015
I have a cancelled service that gives a -1 to an ISCANNED field for each EventDate after the date the services are cancelled. Now I am permitted to Delete all of the cancelled records except the Min() date that =-1.
I built a query to find the value for the First Event date that =-1. I then built a delete query to delete all records after the First Event date that =-1 but it had to Join the "Find the value of the First query" to get the table records to show the records that were going to be deleted.It cannot delete.
Is there a module or VB that can be used to make the delete query work without using the joined "Find the value of the First query"?Something that will say "delete all the records after the first cancelled record"
:confused: Anyone know how to trap/prevent the msg "The DoMenuItem action was cancelled" after answering no to deleting a record? I followed the instructions at the following thread but no luck:
---------------------------------- Private Sub Delete_Click() On Error GoTo Err_Delete_Click DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70 DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70 Exit_Delete_Click: Exit Sub Err_Delete_Click: MsgBox Err.Description Resume Exit_Delete_Click End Sub
----------------------------------- Private Sub Form_Delete(Cancel As Integer) DoCmd.SetWarnings False If MsgBox("Are you sure you want to delete this record?", vbYesNo) = vbNo Then Cancel = True Else MsgBox "Record deleted!" End If End Sub -------------------------------------
I created 3 find unmatched queries from the query wizard. The first one works great. I can delete a record in the query and it deletes the record in the main table.
The second one allows me to delete a record and gives me the pop up box that says " you are about to delete 1 record". I click yes, but when I check the table or reopen the query the same record reappears.
The third query does not even give me the option to delete.
I can create a regular select query and delete the records form 2nd and 3rd but not from the queries made from the unmatched wizard.
I am using the same fields in all 3 queries.
I do not have enforce referential integrity or the other 2 options checked in the relationship properties. (not sure if this makes a difference.)
I even tried to redo the unmatched queries but I get the same result for all 3.
I want to be able to delete the records in the other 2 queries.
I have two simple tables. I want to delete the records from Table1 that are on Table2. I've created a select query that gives me what I want but when I change to a delete query, I get this message: "Unable to delete from specified tables"
I think my problem has something to do with security but I can't figure out what to change.
When we browse through records in a subform we store the records in the database.When we want to delete a records for example the third record from the five records always the first records will be deleted. How can we delete the records where the cursor is at? When we are at the third record and press the delete button the third record from the list in the subform should be deleted.
Code:
Option Compare Database Dim FocusBln As Boolean Private Sub Identificeer() Me.[Datum Aangemaakt].Visible = True Me.[Datum Aangemaakt].SetFocus If Me.[Datum Aangemaakt].Text = "" Then
Hi there, I quickly made a database, and for some reason, can't get past this 'cancelled' error, to get it to occur, open the Companies form, click orders and then it pops up.
By deleting all of the data in my tables, I can get to a state where I can once again enter data, but after closing the orders subform and opening it again, once again I have the dreaded error.
If anyone has any ideas of why this may be happening, feel free to share them :P
Thanks alot, James Prince
Edit,
Here's my table structure:
CompanyID PK Autonumber - Relationship Name Address1 Address2 Town PostalalCode TelephoneNumber FaxNumber
Hey all... I have three searchable fields in my query ATM if i search the MO, and the job code by themselves they don't error out. But if i try searching the FName field. It says "You have canceled the previous operation? Can someone help me with this
I am trying to open a form with a specified record using double clicked event (list box) but access is throwin "The OpenForm action was cancelled". My code is:
Private Sub lstSchool_DblClick(Cancel As Integer) Dim test As String Dim thisForm As String
Setup i have a form (frmCustomers) with a subform (sfrmJobs). As you might have guessed, it keeps track of customers and jobs. One customer may have many jobs. within sfrmJobs are about 300 or so controls for about 300 or so fields (mostly yes/no boxes) and at the moment contains two subforms of its own. customers have an autonumber CustomerID and jobs have a user-entered numeric JobID.
Goal it has been brought to my attention that some jobs may just not work out and must be deemed as "cancelled." however, my client wishes to retain these records rather than delete them. in order to maintain the integrity of the reports, i would like to remove these records from the non-cancelled customer database and place them elsewhere, but still retain the ability to review them if need be (but NOT to modify them).
Problem the job can be cancelled at any point down the line, meaning that a job could have nearly no info or nearly all the info, and everything in between. each job record has a ton of fields. i don't know how to cut and paste an entire record (except for doing it field by field, which could take forever in this instance) into a new table. in this case, it would be several records, since i have a list of materials pertinent to each job as well as a list of services necessary for each job - all of which would have to be removed and placed elsewhere.
Cry for Help what is the best way to go about this? some ideas i had were creating a parallel table for each table used in recording all of the job information and just manually (well, via VBA and recordsets) copying, pasting, then deleting. another is creating a checkbox that when clicked disables every control for the cancelled job (but oy vey that's a lot of controls to code the disabling for) and then have it reflected in my reports that these are only from the NON-cancelled jobs. does anyone else have an idea?
I'm not usre how to handle the error when cancelling a report. so when I hit a control to bring up a report and say I cancel it before I put in any parameters for example I get the dialog box " runtime error" "OpenReport action was cancelled" etc.
Could anyone help me on how to handle this with VBA so that it's at least a more user friendly dialog box?
Hello people of access world forums. I've decided to design a simple access db with 2003 version but with 2000 compatibility and everything appear to work ok.
After designing and testing the db, I have set the Jet user-level security options as described in some documentation and set the startup options too for a "clean type" start. Everything is ok: I have created the workgroup in a new .mdw file, joined the workgroup, set the users, set the groups, protect the forms I wanted to. If I try to open the db, it asks for user and password and the db works as espected about security.
But if I delete, move or change the .mdw filename, the db turns accesible without the implemented security. Only the startup option works but no user is prompted and the protected items turns unprotected.
I would like to know how can I associate the .mdw to the .mdb so I can't access the .mdb if the .mdw file is not present (i.e. copying the .mdb to another computer or something).
I have subform where access lists orderitems(the main form contains the order info). The subform uses a query to lookup items thats in the orderlist. Everything works fine execpt when I change something in a dropdowncombo list in the orderlist sheet(like in sample northwind db) the I get "You cancelled the previous operation". The post IS changed and everything seems to work nice but why do I get this error?
The combo uses "SELECT DISTINCT Items.IDItem, Items.Item FROM Items;" as rowsource and also "ListedItems.IDItem" as controlsource.
The code below is from a form named frmWorkorderComplete I use to append the tblWorkordersComplete table with data from the fields in the table tblWorkOrders. I'm trying to prevent duplicate entries in the tblWorkOrdersComplete table. To do this, I create a unique identifier for each record to be appended by combining the "ordered", "company", and "salescategory" into a string which is inserted into the "wonmbr" primary key field of the tblWorkorderComplete.
The following code is used in the subroutine to check if a particular wonmbr has already been appended. However, I keep receiveing the error: "Runtime Error 2001- You cancelled the previous operation" EVERYTHING else in this sub routine works fine when I remove the offending code:
If DCount("[wonmbr]", "tblWorkorderComplete", "[wonmbr] = str_wonmbr") > 0 Then MsgBox "Workorder Already Appended!" Exit Sub Else
/////////////////////////// Private Sub Archive_Click()
' declare variables Dim Variable1 As String Dim Variable2 As String Dim Variable3 As Date Dim Variable4 As Date Dim Variable5 As Date Dim Variable6 As Date Dim Variable7 As Date Dim str_wonmbr As String Dim strI As String Dim strS As String Dim strSQL As String
' HERE IS THE OFFENDING CODE If DCount("[wonmbr]", "tblWorkorderComplete", "[wonmbr] = str_wonmbr") > 0 Then MsgBox "Workorder Already Archived!" Exit Sub Else
I'm working with an old database and I am getting this error. I have have access 2010. I starting to receive this error after I unlinked one of the tables.
Private Sub Command9_Click() On Error GoTo Err_Command9_Click
Dim stDocName As String Dim stLinkCriteria As String
I have validation on a checkbox on a sub form and after the validation fails and the cancel = true is executed in the before update event, I am unable to select the checkbox on the form. Access will not allow the selection. my subform is called frmContactType so hopefully I am referencing it correctly:
I have a library database that I want to delete a record in my tblStatus when the book is returned. I have found the deleteobject function but it appears that that will delete like a table or query or report or something like that. I have no need to keep track of how many times a certain book has been checked out or that John Doe has checked out books X, Y and Z. As a mater of fact that is exactly what I don't want so I just want to delete the record that says Book ZZZ was checked out by John Doe. When the book is returned I just want it available for some one else.
Hello. I have form. and i need to delete record. Id is a unique key. When i have invisible textbox with source of this key, it's very easy to delete record from database. But is it possible to delete record with query without using textbox?
Hi all, facing a little problem with my forms. Access gives me headaches everyday. Haha.
In a continuous form, I have a delete button with the following code
Private Sub cmdDelete_Click() On Error GoTo Err_cmdDelete_Click
DoCmd.SetWarnings False If MsgBox("Confirm deletion of the record?", vbQuestion + vbYesNo + vbDefaultButton2, "Delete?") = vbYes Then DoCmd.RunCommand acCmdSelectRecord DoCmd.RunCommand acCmdDeleteRecord End If Exit_cmdDelete_Click: DoCmd.SetWarnings True Exit Sub Err_cmdDelete_Click: MsgBox Err.Description Resume Exit_cmdDelete_Click End Sub
However, after the record is deleted, the focus is immediately set to the next field which creates a new record of null data. And since the fields are all required, I am forced to enter data into the new record, if not a pop up will inform to user to enter data.
I do not wish for this new record to be created everytime I delete a row. How do I go about it?
I have a problem with 1 of my form (FrmEditDrawing) that I use to edit a specific record from 1 of my table (TblDrawing). The user will see the Data for each drawing on a form that I called (FrmViewDrawing) and will be able to edit the data for each drawing by clicking a button that will open the form "FrmEditDrawing" on the specific record. In that case I can't edit and change the data for any fields but if I open the form on its own, I can edit and change the data ? I guess it has something to do with the fact that I open twice the same recordsets which locks the table, I am not sure. What would be the different option to solve this problem?
When you want to delete a record out of MS Access, you get the default pop-up message confirming you want to delete the record [YES] [NO].
I have a few users who are not paying attention and hitting a combination of keys (I am guessing Alt + D) and getting this message. They then do not look, and confirm the deletion of the record.
I am thinking of two ways around this.
1) Change the default to [NO] when this pop-up dialog opens up (the default is [YES]).
2) Disable this pop-up box, and then create my own to confirm the deletion.
Are either of these possible, or has anyone ever had to work around this issue? I have never had an issue with this, and was not sure how to attack it.
i have an order form somewhat like the northwind database one. I called mine A5_frmOrders. i have a subform called A6_sfrmOrders, which is in datasheet view. I need to add a "Delete Record" button into the subform, but when i put it in the subform footer, it doesnt appear.
Like any orders subform, i have "Item", "Product", "Quantity", "Unit Price" and "Subtotal" with their corresponding labels in the Detail Section. I tried changnig the subform to "Continuous Form" and doing this : header : Labels for "Item", "Product", "Quantity", "Unit Price" and "Subtotal" detail : "Item", "Product", "Quantity", "Unit Price" and "Subtotal" for user to fill in footer : Delete Record button
but even when i change to Continuous Form, it doesnt allow me to separate "Item" from its label and put one in the header and one in the detail...
how do i add in the delete record button? Is it true i cannot use datasheet view if i want a delete button? Thanks
I have this code on the a Close Button and if the record is incomplete I want it to be deleted from the table. The ID field is an autonumber so it is the 1st field to get a value if a user starts entering data. I get a msg box saying 0 fileds will be deleted why? the id's do match but it does not delete??
Is it possible to delete a record from a table whilst viewing that table through a form. The awkward part though is because I have another table linked to it.
Basically the main table is Orders and the other table is Items (these items make up an order). So when I go to simply click on delete an error message appears saying that I cannot delete the record but there are records attached to it in another table. This is fair enough but is there a smooth way off deleting off the items?