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 
Automatically adding records
Sandi Cushion 
      
2 years ago
I have six tables StaffT, OrderT, OrderDateT, OrderDetailT, ProductT, and WorkLocT
OrderT and OrderDetailT are both on the Many side of the other tables.

I have a main form with a subform.  The main form holds fields StaffID, A combobox from OrderDateT and the source is OrderT.
The subform holds mainly the fields from OrderDetailT with some calculated fields and the source is TimesheetQ

Each Subform shows the monthly staff attendance times and therefore only has 20 records per period.

This is working perfectly.

Now, I am trying to set up a method in which the 20 records are added to the form on the click of a button called 'New Flexi Period'.  
I have tried to do this with an append query (I have a new table with 20 records, the fields have default data which never changes). I am stumped though as to how I add the 20 records to the two Autonumber fields 'OrderDetailT' and 'OrderT'.  

Am I right using the append query method? Or do I need to use VBA in a loop situation.
Sandi Cushion OP  @Reply  
      
2 years ago
There are actually 7 tables.  StaffT is joined to OrderT also.  And StaffID is in the main form.
Matt Hall  @Reply  
          
2 years ago
The append query is what you are looking for.  Check out the Append Query video.
Matt Hall  @Reply  
          
2 years ago
You will not append data into autonumber fields.  They will take care of themselves.

In your button, you will need something like this to run the query:

Private Sub NewFlexiPeriodBtn_Click()
    DoCmd.OpenQuery "appendFlexiQ", acViewNormal, acEdit
End Sub
Sandi Cushion OP  @Reply  
      
2 years ago
Thank you Matt, so do I just omit the two autonumbers when I make the query? I will try this tomorrow when I'm in work.
Matt Hall  @Reply  
          
2 years ago
Yes.  Just populate the fields you want from your "template" table.
Sandi Cushion OP  @Reply  
      
2 years ago
Hi Matt, no this is not working.  I am getting an error saying type conversion failure, key violations, lock violations and validation rule violation".  

Currently, I click the 'new (blank) record'.  At the top of the main form I have a dropdown box to choose a date (from OrderDateT).  These are the valid days which start each Flexi Period.  Another dropdown box to choose the member of staff (from StaffT).  The subform has two dropdown boxes (Product) and (Location)  the product is 1 of 20 days i.e. 1Mon, 1Tue up to 4 Fri (this covers the 20 days of attendance over 4 weeks, and also a Location, Home, Office etc.   I have populated the append table with the primary keys for the dropdown boxes. There is also a date field which is calculated from the product (adding relevant days from OrderDateT.
The primary keys are not allowing me to populate the OrderDetailsT.

I can add the rows manually, but I want the member of staff to be able to click a button and all 20 rows are added.  Help!!
Sandi Cushion OP  @Reply  
      
2 years ago
Solved!  thanks for your help Matt.
Matt Hall  @Reply  
          
2 years ago
Your error message should also give the number of records affected by each type of violation.  What type and how many of each error are you getting?   What table.field's are you trying to append to OrderDetailsT?  

For testing, I would work directly with the underlying table that you want appended (OrderDetailsT) and the append query you are building and deal with the forms after the query is functional.  

If you can post an image of the query and the table, that might help.
Matt Hall  @Reply  
          
2 years ago
I took too long typing...Glad I could help.

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/16/2026 4:12:42 PM. PLT: 0s