Auto Updating Total Order Cost After Quantity is changed (1 Viewer)

dblaszak

New member
Local time
Today, 10:03
Joined
Oct 11, 2006
Messages
4
Ok so here is my problem:
I have a form that is realted to four differnt tables with the names: CUSTOMER, ORDER, PRODUCT AND ORDER LINE. With-in the table Order-Line there is a entity called, line_item_cost whcih is the total amount of the order with respect to Quanity_Ordered which comes from the ORDER LINE table and Price which comes from the PRODUCT table and Discount (%) which comes from the CUSTOMER table. When the users goes to change the Quantity_Ordered I need the form to automaticly update the line_item_cost which would calculate [Price]*[Quantity_Ordred]-[Price]*[Discount] . I tried to build a code in VBA to do this, Here is the Code:
Dim a, b, c, d
a = Me.[Quantity_Ordered]
b = Me.[Price]
c = Me.[Discount]
d = a * b - b* c
Me.[Line_Item_Cost] = d

VBA Complies the program but it does not show up in my form.
I think I might be updating it at the wrong point.
Any Suggestions.????
 

rborob

Registered User.
Local time
Today, 07:03
Joined
Jun 6, 2006
Messages
116
thats very messy

Dim a, b, c, d as double
a = Me.[Quantity_Ordered]
b = Me.[Price]
c = Me.[Discount]
d = ((a*b) - (b*c))
Me.[Line_Item_Cost] = d

tidier. not sure where the problem is though...can you post the database to look at?
 

neileg

AWF VIP
Local time
Today, 14:03
Joined
Dec 4, 2002
Messages
5,975
You should not be storing this value. You can calculate this in a query (your form should be based on queries, not tables, for this and other reasons) or in your form. VBA is not needed.
 

ansentry

Access amateur
Local time
Tomorrow, 01:03
Joined
Jun 1, 2003
Messages
995
What was wrong with this link?

I gave you an answer, which you did not acknowledge as unhelpful, so I assumed it solved your problem.

You have reposted here and created another thread, not only that but you have double posted on another forum.
 

dblaszak

New member
Local time
Today, 10:03
Joined
Oct 11, 2006
Messages
4
Problem With The Query

I tried to do this from the example that you gave me, but I can’t get it to work because my information comes from 4 different tables and I just could not get them to link in the query? Is there anything I can do about that? Sorry I forgot to put down that it was helpful, it was very helpful and I thank you all.
Thanks
dBlaszak
 

Users who are viewing this thread

Top Bottom