Computer Learning Zone CLZ Access Excel Word Windows

Curious fact that those who never fail are also those who never truly succeed.

-Neil deGrasse Tyson
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Visitor Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Record Transaction on 2nd Table
Joe Gomez 

3 years ago
Working with 2 tables (tblLoans and tblLoanPayments)
For every instance where a loan is past due (tblLoans) I need to post a late charge in the tblLoanPayments

Dim tblLoans As DAO.Recordset
Dim rs As DAO.Recordset
Dim lRecCount As Long, i as integer, ii as integer
Dim HowmanytimesLate as integer, late
lRecCount = DCount("*", "tblLoans")
DoCmd.GoToRecord , , acFirst
late = True          '... for illustration
HowmanytimesLate = 5 '...for illustration

For i = 1 To lRecCount
   If late
     For ii to howmanytimeslate
        'I run this
         DoCmd.RunSQL "INSERT INTO tblLoanPayments (LoanNo,......
        'Or this ---but not both
        'DoCmd.OpenForm "frmAssessLateFeeRecording"...
     Next ii
     DoCmd.GoToRecord , , acNext - I get error right here
Next i


Problem is that when the DoCmd.RunSQL "INSERT INTO tblLoanPayments OR theDoCmd.OpenForm "frmAssessLateFeeRecording"... to record a transaction on tblLoanPayments and comes back here, I get error going to next record.

The error: Run-time error '2499':
You can't use the GoToRecord or SearchForRecord action or method on an object in design view --- but am not in design - and again... if I don't run the DoCmd to write the transaction, it all works perfectly, makes its calculation and updates the table loans properly

several steps were omitted afraid I would hit limit of 2000 characters, but I think the idea is there, hope it makes sense...


Kevin Robertson  @Reply  
           
3 years ago
Recordsets start in: Access Developer 16.
I would use a While Wend Loop.

Old Tip: Using Recordsets
Since you are in a recordset use rs.AddNew to add the record to the table.

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Visitor 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: 5/6/2026 8:28:14 AM. PLT: 0s