Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
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
  #1 (permalink)  
Old August 30th, 2004, 12:25 AM
Registered User
 
Join Date: Jul 2004
Location: , , .
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default Storing Calculated Fields

I have a calculated field called Saving which I want to store in the table. I know this isn't advisable, but I need to refer back to it constantly and want to know what the savings are when the information was entered. Does anyone know a way to do this?

  #2 (permalink)  
Old August 30th, 2004, 10:54 AM
SGL SGL is offline
Registered User
 
Join Date: Aug 2004
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

First, add a field to the appropriate table where you will store your calculated field.

Second, bind your calculated control field to that form.

Third, make that control calculated field locked.

Fourth, write a VBA procedure that does the calculation. For example:

Me!CalcField = Me!Cost - Me!Discount

Fifth, set before update events for each field used to do the calculation that call the procedure you wrote above.

Sixth, set the on enter event of the calculated field to also call that procedure and do the calcuation. This should be unnecessary but it is an extra safety step.


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to create calculated fields MacDevv C# 3 August 16th, 2006 09:38 AM
Nested Calculated Fields in Queries SerranoG Access 0 August 14th, 2006 10:04 AM
Storing Calculated Fields dearnne Access 3 September 2nd, 2004 05:30 PM
Summing the Results of Two Calculated Fields CloudNine Access 1 December 24th, 2003 12:05 PM





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