Solved

Adding fields using VBA in Access 2007

Posted on 2013-05-16
1
481 Views
Last Modified: 2013-05-20
In my database there is a table called "tbl_Shrinkage" which has the LineNumber, YearMo, HDLR fields that I need to use to tell the vba code what to add.  If the "YearMo" and "HDLR" and the line number is between 1 and 6, I need to total up the Prod_Lbs, SK_LBS, BF_LBS and put it in a table called "tbl_PutDataInto" and in that table for the line number field update that to a 7.  Essentially the YearMO and the HDLR fields have to be the same ie. I want the totals for Prod_LBS, SK_LBS, BF_LBS  for line 1 thru 6 for 201201 (the month of Jan.) for HDLR 020 and put it into a separate table using VBA.
Testing.accdb
0
Comment
Question by:MTMonday
1 Comment
 
LVL 57

Accepted Solution

by:
Jim Dettman (Microsoft MVP/ EE MVE) earned 500 total points
ID: 39171434
I don't see why you would need code at all, but simply a query.

Start off building it step by step:

1. Construct a query that looks tbl_Shrinkage.  Make it a Totals query, grouping on YearMO and HDLR fields, a criteria on the line number, and total the Prod_Lbs, SK_LBS, BF_LBS fields.  Save the query.

2. Construct a Insert query to tbl_PutDataInto using query from #1 as a table, and insert the data into tbl_PutDataInto.

  You can execute query #2 from VBA or a macro.

Jim.
0

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Leon
Software Metering within our group of companies has always been an afterthought until auditing of software and licensing became a pain point. Orchestrator and SCCM metering gave us the answer and it was an exciting process.
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
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…

839 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