?
Solved

Adding fields using VBA in Access 2007

Posted on 2013-05-16
1
Medium Priority
?
492 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 58

Accepted Solution

by:
Jim Dettman (Microsoft MVP/ EE MVE) earned 1000 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

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

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

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

801 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