Undo Delete Records

May 2, 2006

Hi,

I have a question.

How can I make undo delete records?

When the user select all the records, and then click "delete" key. Then it will delete all records.

I want to setup that there must be at least 1 record left.

If they select all the records and delete all, then it will undo delete all records. We have to keep at least 1 record.

What command to undo delete all records?

Please let me know, thanks.

View Replies


ADVERTISEMENT

General :: How To Undo Delete Command In Datasheet View

Jul 9, 2013

When I had a subform (continous form) I had a code which check, that record was used in other form, if yes, then code not allowed to delete this record, if not, record was deleted. But now I have a datasheet form, and the question is, What should I do, to have the same results what I had in continous form.

Now it doesn't matter that I past this code in "Before Del Confirm", "On delete", "After Del Confirm", this code doesn't work in this view of form. Always if I click (right button) on record, then i choose "delete record" MS Access delete my record without checking that was used in other form or not.

Code:
If Not IsNull(DLookup("Id_Gora_Zlecenia.Value", "TblDolZlecenia", "Id_Gora_Zlecenia.Value=" & ID_gora_zlecenia)) Then
MsgBox "You can't delete this record because it is used in another form"
Exit Sub
End If
DeleteRecord Me
End Sub

DeleteRecord:

Code:
Public Function DeleteRecord(ByRef f As Form) As Boolean
DeleteRecord = False
On Error Resume Next
DoCmd.SetWarnings False
If Not f.NewRecord Then
DoCmd.RunCommand acCmdDeleteRecord

[Code] .....

View 14 Replies View Related

Forms :: Why To Undo Edits After Changed Records In A Form

Jul 22, 2013

I thought "Undo" was only available while in the current record.Here were my steps:

1 - Loaded form that shows 1 record per form page.
2 - Edited a record
3 - Moved to another record with status bar nav arrow
4 - Verified my edit was in the underlying table
5 - Moved back to the original record, again using status bar nav arrow
6 - Clicked my "undo" control and the original data appeared in the form
7 - Moved to another record
8 - Verified my original data was now back in the underlying table

My undo control has this vba on click:

Code:
DoCmd.RunCommand acCmdUndo

View 1 Replies View Related

Undo Won't Undo Last Function.

May 4, 2006

I have a Memo box where the user puts comments and then I have a check box that if check automatically puts a specific phrase on the first line of the Memo box (before any other text currently in the box). What I am trying to do is have it so that if the "check box" is UN-checked it will remove the line that it just added to the Memo box. I have been able to get it to undo everything in the Memo box, but what I really need is for it to just undo the last line of text that was enterd when the user checked the box.

Example:

Memo Box:
This is the line that the checkbox just added when the checkbox is set to "True"
This is the test data the user has already put in the box...
==================

User now UN-checks the checkbox (I want the Memo box to read.. see below) Thereby deleting the line "This is the line that the checkbox just added when the checkbox is set to "True""

Memo Box:
This is the test data the user has already put in the box...

How can I accomplish this?

View 1 Replies View Related

Undo, Won't Undo - Do I Understand Right?

Nov 14, 2006

Hi, I have found the answer to most of my problem, thanks to previous posts.
I am using the Undo command on a Date field. However it seems that my code is maybe not staying on the event to action the undo.

After it runs the Focus goes to the next field Me.LeaveDays and the value is automatically entered, unless I comment back in the Goto's in which case the value will be zero.

I want to be able to Undo the EndDate (and preferable the StartDate, and Setfocus to StartDate) EndDate will do if not possible.

Don't want to Undo the whole form, although that could be a last resort.

My code is in the before_update event, image posted (ignore faded fields, not visible/needed in final solution)
Private Sub EndDate_BeforeUpdate(Cancel As Integer)
On Error GoTo Err_EndDate_BeforeUpdate

Dim intLeaveLeftAL As Integer
Dim intLeaveLeftSL As Integer
Dim intLeaveDays As Integer
Dim dtNullDate As Date
Dim varNullField As Variant

intLeaveLeftAL = Nz(Forms!frmAddLeaveRecords.fsubLeaveAgTots.Form![DailyALInc] - (Forms!frmAddLeaveRecords.fsubLeaveAgTots.Form![ALDays] - Forms!frmAddLeaveRecords.fsubLeaveAgTots.Form![ACDays]), 0)
intLeaveLeftSL = Nz(10 - Forms!frmAddLeaveRecords.fsubLeaveAgTots.Form![SLDays], 0)

' Use the WorkingDays function to calc the number of Leave Days
' set LeaveDays and requery the form
intLeaveDays = WorkingDays(Me.StartDate, Me.EndDate)

If Me.LCode = "LC41" Then ' Sick Leave

Select Case intLeaveDays
Case Is > intLeaveLeftSL
MsgBox "Employee does not have enough Leave" & vbCrLf & "to take as Sick Leave.", vbCritical + vbOKOnly + vbDefaultButton1, "Entry in Error"
varErrorCondition = True
Me.EndDate.Undo
GoTo Exit_EndDate_BeforeUpdate
Case Else:
End Select

ElseIf Me.LCode = "LC11" Or Me.LCode = "LC13c" Then ' Annual or C/Fwd Leave

Select Case intLeaveDays
Case Is > intLeaveLeftAL
MsgBox "Employee does not have enough Leave" & vbCrLf & "to take as Annual Leave.", vbCritical + vbOKOnly + vbDefaultButton1, "Entry in Error"
varErrorCondition = True
Me.EndDate.Undo
GoTo Exit_EndDate_BeforeUpdate
Case Else:
End Select
End If

Me.LeaveDays = intLeaveDays
Me.LeaveDays.Requery
varErrorCondition = False

Exit_EndDate_BeforeUpdate:
Exit Sub

Err_EndDate_BeforeUpdate:
MsgBox Err.Number & " - " & Err.Description
Resume Exit_EndDate_BeforeUpdate

End Sub
The ifs and cases work fine, just like to send the User back a few steps
appreciated :) :)

View 9 Replies View Related

Modules & VBA :: Delete Records From A Table Based On Records In Another

Feb 7, 2014

I have a table InvPrice and Updated Pricing

Need to delete all records from InvPrice that Match UpdatedPricing

InvPrice.StockCode = UpdatedPricing.StockCode
InvPrice.PriceCode = UpdatedPricing.StockCode

I have tried something like this...

Dim dbs As DAO.Database, sql As String, rCount As Integer
Set dbs = CurrentDb
sql = "DELETE * dbo_InvPrice Inner Join (dbo_InvPrice Inner Join UpdatedPricing on dbo_InvPrice.StockCode = UpdatedPricing.StockCode ) ON on dbo_INvPrice.PriceCode = UpdatedPricing.PriceCode "
dbs.Execute sql, dbFailOnError

View 14 Replies View Related

Delete Duplicate Records Or Blank Records

Mar 19, 2007

I want to find duplicate records based on FirstName and LastName and delete the duplicate. Also, I want to delete any records which have a blank FirstName and LastName.

How can I do this?

Thanks,

Dave

View 3 Replies View Related

Cannot Delete Records

Jan 8, 2007

I have a query of records that are not related to records is the secondary table. I want to delete these records but when I select the records and click delete I get the confirmation to delete answer to delete them and all the records disappear. When I run the query again, all the records are still there. Does anyone know what is happening? This is an access front end that connects to a SQL server database.

View 1 Replies View Related

Delete Records

Apr 6, 2007

This works perfectly.

SELECT DOCSADM_PROFILE.SYSTEM_ID, DOCSADM_PROFILE.AUTHOR, DOCSADM_SECURITY.THING, DOCSADM_SECURITY.PERSONORGROUP, DOCSADM_SECURITY.ACCESSRIGHTS
FROM DOCSADM_PROFILE INNER JOIN DOCSADM_SECURITY ON DOCSADM_PROFILE.SYSTEM_ID = DOCSADM_SECURITY.THING
WHERE (((DOCSADM_PROFILE.AUTHOR)=21941909) AND ((DOCSADM_SECURITY.PERSONORGROUP)=4038));

Now how do i tell this query to delete these selected records from security table....?

View 6 Replies View Related

Delete Records

Mar 17, 2005

I have a survey form that has the questions on a subform based on the response to one of the survey demographic questions (via a query based on that response). The answers to the questions are on a sub-sub form. How can I get the program to delete the answers that were entered (they are related to the primary survey form with a common ID number) if the user changes the survey response.

In other words, if the user of SurveyID 5 decides that they want to fill out the list of blue questions rather than red questions, how can I delete all the answer blue records for SurveyID 5? Right now, it will display the red questions if you change to red and enter red answers, but the blue answers remain in the database, creating 2 sets of answers for SurveyID 5.

Any suggestions...if this is not too confusing?
Thanks!

View 1 Replies View Related

Cannot Add Or Delete Records

Dec 25, 2004

Hello all:

Form created based on a query. When i go to the form, the add new record and delete record buttons are disabled.

I have checked and re-checked the form, tables, queries and all seems well.

Does anyone know how I can fix this problem?

Many thanks,

Dion

View 2 Replies View Related

Delete Records Except First

Jun 1, 2014

possible to delete all records from one table except the first; Is that possible?

View 7 Replies View Related

Delete Records Problem

Jun 8, 2005

Good evening,

I am experiencing a problem with the delete buttons I have added into my forms. I have 3 different forms that operators use, I added a delete button using the wizard on each form to delete the data if the user makes a mistake. I have allowed deletes in the form properties. My problem is that the button only works on one of the forms. I have checked the code and it is the same on all 3 forms.

The record is not deleted, all that happens is that the vertical bar down the LHS of the form flashes black, and thats about it

Private Sub Command52_Click()
On Error GoTo Err_Command52_Click


DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70

Exit_Command52_Click:
Exit Sub

Err_Command52_Click:
MsgBox Err.Description
Resume Exit_Command52_Click

End Sub

Any thoughts?

The only difference is that one button is called Command52 and the other one is called Delete

Russ

View 4 Replies View Related

How To Delete Duplicate Records

Apr 30, 2007

Hello,

I have a table that has many duplicate records. I tried importing the table and setting the field to no duplicates but did not work. How can I delete duplicate records. The primary Id id fine I have another field that I can use. it is a BAC number that is repeated many times. Here is the table I need fixed.

Thanks

View 1 Replies View Related

Auto Delete Records?

Jul 29, 2005

I am creating a web database where users submit entries using an online form. When they submit the entry, I am saving the entry date and time in a column called Timestamp. What I need to figure out is if there is a way to create some sort of expiration date, based on the Timestamp, that will automatically delete a record after it is 7 days old. Is there a way to do this? Thanks so much for any help that you can give.

View 5 Replies View Related

Delete Multiple Records

May 9, 2007

how do i delete multiple records in a table, for example if i have a table that as serial_num 123 twice, how do i delete the two records, basically i don't want to delete one record, i want to delete the two records. Thanks.

View 5 Replies View Related

How To Delete Multiple Records

Aug 15, 2005

Hi,

I'm trying to delete say 4000 records, out of total 5000 records. I want to keep 1000 records based on the ID.

How can I write the SQL DELETE query, so that only 1000 records remain based on the query?

Thank you in advance for your great help.

regards,
Pranesh
Alberta, Canada

View 1 Replies View Related

Delete Records From A Table

Oct 26, 2005

Hi

I'm trying to deleterecords from one table. In the query there are 2 tables both joined. I get an error message come on saying

"Specify The Table Containing The Records you want to Delete"

Below is the query in SQL

DELETE tblStockRequired.StockCode, tblStockRequired.StockQTY, tblStockRequired.OrderNumber
FROM tblOrderCompleted INNER JOIN tblStockRequired ON (tblOrderCompleted.OrderNumber = tblStockRequired.OrderNumber) AND (tblOrderCompleted.StockCode = tblStockRequired.StockCode) AND (tblOrderCompleted.QTY = tblStockRequired.StockQTY);

I want ot delete all records from tblStockRequired which match up with tblOrderCompleted.

Thanks in Advanced

View 2 Replies View Related

Delete Matching Records

Feb 27, 2006

Hi can anyone please help me out. How can I delete records from one table, where matching in a second table?

View 1 Replies View Related

Delete Similar Records

Jul 31, 2006

I have a table of ~165k records and need to delete records that are similar (2 or more records have the same lastname, firstname, dob). These records are not duplicates as other field values in these records are different. I've tried several sql scripts and Access methodologies but can't get valid results.

Thanks,
Phil....

View 1 Replies View Related

Delete Records For Last Month

Oct 16, 2007

Hi All.
I need to modify my database that give me ability to delete all record form table for last month. How to solve that problem?
Thanks.

View 9 Replies View Related

Duplicate Records Delete

Jan 14, 2008

On the below data I need to delete records where dep is blank or the same for the same ID. So I need to find and del recNr. 1,4,5. Any help will be appreceated!Thanks

recNr IDDep
1 ABX
2 ABX 1234
3 ABX 1258
4 CDE
5 CDE 7895
6 CDE 7895

View 5 Replies View Related

Delete Records From A Listbox

Apr 14, 2005

I have a form with a listbox on it and I am trying to make a button that will delete the selected records from a table. The List box is filled from a query. Any help would be very appreciated.

Table to delete records from = tbllinkPersonel_Training
listbox = lstTraining_In

_______________________________________________
Private Sub cmdDelete_Click()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim var As Variant
Set db = CurrentDb
Set rs = db.OpenRecordset("tbllinkPersonel_Training")

If IsNull(Me.cboTraining) Then
MsgBox "No Class selected...", vbExclamation
Exit Sub
End If

For Each var In Me.lstTraining_In.ItemsSelected
With rs
.Delete
End With
Next

MsgBox "Deleted Successfully...", vbInformation

rs.Close
db.Close

Set rs = Nothing
Set db = Nothing

Me.lstTraining_In.Requery
Me.lstpersonel.Requery
End Sub
____________________________________________

Thanks, Michael

View 7 Replies View Related

How To Delete Records By Right Click

Dec 1, 2005

Is there a way upon selecting a record (in a continuous form db) I could right click and delete the record? I am able to cut, copy and paste but unable to delete. Any suggestions?

Thanks.

View 2 Replies View Related

Delete Duplicate Records

Feb 2, 2006

Help please!
I have a form (frmHalfTab) built on a table (tblHalfTab2) that has existing data in it. In the very near future, I will be uploading additional data to this table via excel cut and paste. What I want to do is search for and eliminate duplicate records that have duplicate data in TWO fields, (MemberNum) and (MBRDrug), so that if MemberNum is "10" and MBRDrug is "Zzz" for more than one record, the duplicated records need to be deleted, OR a check box needs to be checked automatically for all the identical records, the original and the duplicate(s). I wanted to put this behind a button, if possible.

Now, I have created a duplicate query that will find the duplicated records, but I'm not sure how to use it to get rid of the duplicated records or check the checkbox appropriately. Should I ditch this query and choose a different route, or am I on the right track? Thanks in advance for your help.:confused:

View 2 Replies View Related

Automatically Delete Records

Mar 28, 2006

I have 2 forms:
one called basic the other called advance

how can i automatically delete records from the basic table, when students are advance.

thanks 4 helping

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved