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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calculating price totals 2

Status
Not open for further replies.

mishmish

Programmer
May 25, 2001
27
0
0
US
Hi,

I have a shopping cart form with a series of orders and their respective prices. The orders and prices are in a subform. I want to put a total price text box underneath this subform that will calculate all of the prices from the subform.

Does anyone know how I would do this?

Thanks for any help,
mishmish
 
Place the textbox in the subform's footer section and try using the DSum function in the ControlSource property.
 
Hi,

Thanks for your response. Yeah, the sum is totaling my currency values. However, it's not converting the values to a currency datatype in my textbox. For example, I'm getting "160" and not "$160.00." The "ExtendedPrice" field below in my code is a Currency datatype.

This is my code:
Dim totalX As Currency
totalX = DSum("[ExtendedPrice]", "QuoteLine")
txtTotalPrice = totalX


Any ideas?

Thanks again,
mishmish


 
Not sure why you need the code,

in the subform place a textbox in the footer (call it txtTotal), then place this in its control source
=Sum([Price])

enure the box is format is set to currency.

If you want this value on the main form instead of the sub form. Then hide the footer of the subform and reference the value in the hidden text box in the main form.

Therefore the textbox controlsource on the main would be set to:
=[subfrmName].[Form]![txtTotal]
 
Hi,

Thanks. Good tips. That worked.

mishmish
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top