Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Help   Contact   Merch   Join   Order   Logon   Forums   
 
Home > TechHelp > Directory > Access > Set Quarter And Year In BeforeInsert by Kim Hall >
Back to Access TechHelp    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Set Quarter And Year In BeforeInsert
Kim Hall 
    
3 days ago
I want to record quarterly data without having to type the quarter and CY for each record (well over 300). Google suggested putting the Qtr and CY in the Header, then put them in the detail section with the default value set as =[txtMasterValueQtr]  and =[TxtmasterValueCY]. This is not working. The last attempt added the Calendar Year but not the Quarter.  After these to fields I record the employees name and Employee Code (which is the key field). I also add 17 other number fields. Some of those fields add together to give total fields for data entry verification. What would you recommend to get the Qtr and CY added to each record? I need this information for Qtrly report sorting.
Richard Rost  @Reply  
           
3 days ago
Put the Quarter and Calendar Year controls in the Form Header, but don't try to use them as Default Values for bound fields. A Default Value is evaluated when the new record is created, and a reference to a header control can be unreliable in that context.

The method I would use is to set the fields in the form's BeforeInsert event. That event fires once, when the user starts entering a new record:

Private Sub Form_BeforeInsert(Cancel As Integer)
    Qtr = txtMasterValueQtr
    CY = txtMasterValueCY
End Sub


Of course, use your actual field/control names. If your bound fields are named Qtr and CY, and your unbound header controls are txtMasterValueQtr and txtMasterValueCY, the code above will copy the values into every new detail record.

Make sure the Quarter and Calendar Year fields are included in the form's Record Source and that the controls in the Detail section are bound to those fields. You can hide those detail controls afterward if you don't need users changing them individually.

Also, Employee Code probably should not be the primary key if an employee will have quarterly records more than once. You will eventually need more than one record for the same employee. I would normally use an AutoNumber ID field as the primary key, then use a unique index on EmployeeCode, Qtr, and CY if you want to prevent entering the same employee twice for the same quarter.
Kim Hall OP  @Reply  
    
3 days ago
Thank you!
Add a Reply Upload an Image
Next Unseen

 
 
What's This?

 

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: 9/25/2026 1:25:14 PM. PLT: 1s