Solved

How delete only new records in a continuous form

Posted on 2016-11-16
6
17 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 49

Expert Comment

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

/gustav
0
 

Author Comment

by:SteveL13
Comment Utility
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 49

Accepted Solution

by:
Gustav Brock earned 500 total points
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 34

Expert Comment

by:PatHartman
Comment Utility
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
Comment Utility
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
Comment Utility
I added a "Delete Record" checkbox to the table and the form.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

762 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now