Solved

Adding fields using VBA in Access 2007

Posted on 2013-05-16
1
477 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
Comment Utility
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Many companies are making the switch from Microsoft to Google Apps (https://www.google.com/work/apps/business/). Use this article to learn more about what Google Apps has to offer and to help if you’re planning on migrating to Google Apps. It is …
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

763 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now