Simple form totalling error

davidbodhi

Davidbodhi
Local time
Yesterday, 19:47
Joined
Jul 6, 2005
Messages
79
I am making a simple tabular form to use as a subform in another.

The form has a cbo box (cboItem_Name)
Quantity (txtQuantity)
Price (txtItem_Cost)
Extended Price (txtExtended_Price)

Selecting an item in the combo puts the price in txtItem_Cost. Default for Quantity is 1. Control Source for txtExtended_Price = [txtQuantity]*[txtItem_Cost] and gives me my extended price.

I have a control in the footer of the form called txtSub_Total. It's Control Source =SUM([txtExtended_Price]).
This Sub Total box generates the #error.

Can anyone tell me why? Do I need to do some other magic with my txtExtended_Price control instead of a simple calculation, like I have?

Thanks for any help you can give a novice.
 
I think the reason you are getting an #error is because field [txtExtended_Price] isn't a field on your main form. Because of this you have to point Access to where this control exists. Something like Sum([Forms]![SubForm]![txtExtended_Price])

Still, even if you fixed your reference problem I don't think that solution will work. It will probably only show you the price of the first or last record. My question: are these costs and prices stored in a table and are these tabular fields bound to these table fields? If so you might be able to use something like this in the ControlSource of your SubTotal field: =DSum("[ExtendedPrice]","tblTabular","[ItemID]=" & [Forms]![Form]![ItemID] & ")

That should work, although it might not reflect the latest tabular record's data until the focus was moved off that record and it was saved. Otherwise, I'm sort of out of ideas. See how far this takes you...
 
Simple form - totalling error STILL

Thanks, Iago, but so far I'm just looking at the tabular form on it's own, outside the main form. From what I've read, in my reference book, here on the forum and in looking at the Northwinds sample, putting =SUM(fieldname) in the footer of the form ought to total up however many instances of "fieldname" you have.

I've moved the calculation of txtExtended_Price to an AfterUpdate event for the txtQuantity control. (My extended price was not being saved in the table.) I still get the #error, however, from my form footer txtSub_Total whose Control Source =SUM([txtExtended_Price]).

This is the exact Control Source used in the Northwinds sample. Of course, in that sample I can't even find where the extended price calculation is occuring, so what does that mean...
 
Last edited:

Users who are viewing this thread

Back
Top Bottom