Solved

How delete only new records in a continuous form

Posted on 2016-11-16
6
53 Views
Last Modified: 2016-11-16
I have a continuous form that displays existing records but also allows the user to add new records.  My question is this, via a command button, if the user decides they did not want to add the new records they keyed in, can those new records be deleted and keep the existing records and if so, what would that code look like?
0
Comment
Question by:SteveL13
6 Comments
 
LVL 50

Expert Comment

by:Gustav Brock
ID: 41889636
Yes. Just mark the records (the record selector at far left) and press Delete.

/gustav
0
 

Author Comment

by:SteveL13
ID: 41889641
Yes, I know it can be done that way.  But I need to make it easy for a novice via a command button.
0
 
LVL 50

Accepted Solution

by:
Gustav Brock earned 500 total points
ID: 41889662
You can run this code if you can define the condition for a "new" record:

Dim rs As DAO.Recordset

Set rs = Me.RecordsetClone
While Not rs.EOF
    If (<condition for a "new" record>) = True Then
        rs.Delete
    End If
    rs.MoveNext
Wend
Set rs = Nothing

Open in new window

/gustav
0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
LVL 36

Expert Comment

by:PatHartman
ID: 41889795
What is "new"?  Added today, added in the last hour, added in the last 5 minutes, added by this user?

At a minimum you need to add DateAdded and AddedBy fields to the table.  Then you would use the specific timing interval you choose and the Added by to choose which records to delete.  Although forcing the user to choose individual records and then validating the timing and person is far safer.
0
 
LVL 30

Expert Comment

by:hnasr
ID: 41889841
This feature is similar to record activation for software or accounts.

You may add a field with default value, pending activation.
A button to accept the records, by updating pending activation to active.
A button to delete pending activation.

You may filter deletion for a period of time.
0
 

Author Closing Comment

by:SteveL13
ID: 41890206
I added a "Delete Record" checkbox to the table and the form.
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question