Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Access Developer Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Manipulating Recordsets
Glenn Taylor 
    
5 years ago
A complex query produces a Recordset which is very useful in a report. But to refine the data to serve another purpose requires the removal of one or more records from this Recordset based on refined criteria. Using the rst.Delete command (VBA) to remove an unwanted record causes a "read-only" error (3027). I suspect the only way around this might be to write the records from the Recordset you want to keep to a temp table and then send the resultant temp table records to the report. Can anyone think of another workaround where the creation of a temp table is unnecessary?
Alex Hedley  @Reply  
           
5 years ago
What is your criteria for removal?
Why can't that just be added to a new query which is based from your original?
Glenn Taylor OP  @Reply  
    
5 years ago
The Recordset has 5 fields and if three of these fields are the same the second and subsequent records are thrown away. The query is a UNION query, quite complex. I really need to evaluate each record against it's adjacent (sorted) record for duplicates in these three fields so VBA seems to be a logical choice. I have the VBA working fine except it throws the error when I do find a record which needs to be discarded and make an attempt to delete it. I'm about ready to create the temp table to just get through this issue and move on. It would just be elegant to just run through the Recordset and toss those which aren't wanted and then feed the report with the modified Recordset. I guess that would make it too easy :-)
Scott Axton  @Reply  
        
5 years ago
Glenn could you add a field, called "DelFlag" for instance, and then update that field to true with your record set?
Then feed the report with the data where the DelFlag = False?

Are you permanently deleting the record from your db?  
I've found this helps in that case also.  First mark the records for deletion.  Then delete the records that are marked.  I've had issues deleting one at a time "on the fly" before and this method solved my problems.
Scott Axton  @Reply  
        
5 years ago
Even that solution may not be of value to you.   Due to the complexity of your query.
See the video:  Not Updateable
Glenn Taylor OP  @Reply  
    
5 years ago
In deciding whether to set this additional field to True or False, I might as well just perform the delete operation. I can't have dissimilar fields in the UNION so the "manipulation" of the results can best be addressed in VBA code, which is pretty simple with a couple of if's. The complexity of this is the result of tracking miles traveled to businesses or clients and combining that with distances traveled to FedEx and USPS, for instance. The business travel doesn't require shipping so it's in a "tblTransaction" table (for lack of a better word) and the shipping is in a tblShipping table linked to the "tblTransaction" table, but it's conditional in that the shipping is done from our office to a shipping station and not a client or agency shipping to us. We have to keep track of all routes that documents take throughout the process. Thanks for your contributions to this dilemma.
Glenn Taylor OP  @Reply  
    
5 years ago
To answer your direct question, Scott, no we are not deleting any records from any database tables, simply reporting of the contents in a way that can be used for other reports (in this case, business travel for tax reporting purposes).
Glenn Taylor OP  @Reply  
    
5 years ago
Another option that came to mind (even though I wouldn't know how to do this) is to skip records with have the same info in the three fields from being output in the report by filtering within the detailed section of the report itself (seems like a jury rigged implementation). I might experiment with something simple to validate this method. It would certainly educate me on how records are processed within this report event!!
Richard Rost  @Reply  
           
5 years ago
Feed your Union Query into an Aggregate Query to remove the duplicates (Group By).
Glenn Taylor OP  @Reply  
    
5 years ago
I ended up using a table and as I processed the records via VBA, saved off the one's I wanted to the table. I then fed the report from the table's record source. Using an aggregate query would be problematic since there is additional processing if records are "deemed" to be duplicates. By that I mean they aren't really duplicates in the purest sense, only certain fields match each other and even that some of those fields might have "FxE" or "FxG", but are considered "duplicates" since I only take one trip to FedEx whether I'm shipping a package via FxE or FxG (Ground). So the processing is a little more complex than just looking for pure duplicates. The solution works very well. I can deal with the fact that I can't delete the table within the VBA or when exiting the output form but I do delete the table when I start a new DB session.

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Developer Forum.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 6/22/2026 3:18:03 PM. PLT: 0s