Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calculation of a control on form 2

Status
Not open for further replies.

FrankMars

Technical User
Dec 20, 2010
67
US
I am a beginner with Access. I fill out a form monthly in which I enter the current price of several items I am monitoring. I am editing an already existing record which was created a month or more earlier. When I enter the current price I would like Access to tell me the difference between the price I am entering and the price I am overwriting. Is this possible?
 
Each control has a buffer. It stores the oldvalue.
So in the afterupdate of the control.
Me.YourControlName.oldValue would give the old value
Me.YourControlName.value would give the new value.
 
Thanks guys - I'm working with your suggestions. A related question - In addition to obtaining the price difference each month, how would I best keep a price history for each record (several months of price changes)?
 
After rereading you original post, I see that you are overwriting the price. You need to set up your tables correctly and use the power of relational databases.

You should have an Item table which had fields unique to an item. Something like
tblItems
itemID (primary key, and could be an autonumber)
itemDescription
otherItemFields (photo, category, make, serial,....)

then have a one to many table of prices, because you will have many prices for each item.

tblItemPrices
itemID_fk ( a key that relates back to the tblItems)
curPrice (a currency field for the price)
dtmPriceDate (a date field, for that price)

Using queries you can bring it all back together linking the two tables by itemID.

You would likely have a Main form for the item and a subform with the related prices for that item. You may want to look at the Northwind demo that ships with Access.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top