Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 20th, 2009, 11:21 AM
Registered User
 
Join Date: Feb 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default updating database calculated field through VB code

i'm new to VB and Access and this is my situation:
i have a database with different fields such as CUSTOMER_ID, CUSTOMER_NAME, CUSTOMER_TOTAL $
everyday i get new information about some customers with these same fields but the CUSTOMER_TOTAL $ field might have a different number. i'm going to have this new information in a new table in the database.
now what i want to do is somehow use some coding that allows me to:
look in the new data if any of the customers in the main table has a new CUSTOMER_TOTAL $ value in the new data, and add the new value to the value in the master table. we will be doing this same operation daily so i will also need some way of storing the code so i don't have to re-type it every time

i was thinking that this could be done somehow through VB coding, but i don't know how to do it. whatever info will be greatly appreciated
 
Old February 23rd, 2009, 12:42 PM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

So you will have two tables that look like this:

tblCustomer
CustomerID
CustomerName
CustomerTotal (is this a running total?

tblTransaction
TransactionID
CustomerID - look up to tblCustomer
TransactionTotal

and that last line needs to be added into the CustomerTotal in tblCustomer?

First question: Why would you do this when this design without CustomerTotal in tblCustomer will yield the Customer Total with a simple query? No need to transfer all these totals to tblCustomer since they are already joined such that a simple query / report will yeild the current customer total in real time.

Storing this kind of totaled number in a table is not generally called for in database design. Is there a reason you need to store this value when it is stored already?

Code:
SELECT tblCustomer.CustomerName, Sum(tblTransaction.TransactionTotal) AS SumOfTransactionTotal
FROM tblCustomer INNER JOIN tblTransaction ON tblCustomer.CustomerID = tblTransaction.CustomerID
GROUP BY tblCustomer.CustomerName;
__________________
mmcdonal

Look it up at: http://wrox.books24x7.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
Updating VBA calculated Text Box throught Report wintermute Access VBA 2 March 28th, 2008 12:00 PM
VB.Net Code for updating a record damanka2001 Access VBA 0 July 26th, 2007 04:59 PM
How to create a Calculated Field fdtoo SQL Server 2000 0 April 11th, 2006 08:34 PM
updating yes/no field in MS Access database enigma82 Classic ASP Databases 2 May 6th, 2005 11:04 AM
Auto Calculated Field in Access anubhav.kumar Access 1 March 15th, 2005 08:37 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.