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

Problem with form text box expression updating table 1

Status
Not open for further replies.

murpl

Technical User
Mar 1, 2001
32
CA
This is a two-parter akshooly. :p
In MS Access2K I've added a text box to a form to display to the user the retail price of an item. It's a subform contained within a form and I've simply typed an expression in the text box I created by dragging from the table to the form whilst creating the form in design view. It displays the correct data but the corresponding table field doesn't get the value for that record even though the other ones do. Did I lose the field association for that control when I entered the expression?
Also, can I display that same value on the form that contains this subform? How? I tried this:
Code:
=[Products Subform].FORM![UnitPrice]
to no avail.
Thanks (again), Mike
 
If you are trying to display say, the orders sum total of all the unit prices on to the main form, first create a text box in the subforms form footer. Name it TxtSubTotal. its control source might be something like:
=Sum([Quantity]*([Unit Price]-([Unit Price]*[Discount])))

Now make a text box on your main form. Call it what you want and its control source should be like:
=[NameOfYourSubFormAsSeenByTheMainForm].Form![TxtSubtotal]

Make sure your unit price text box is bound to the field "unit price".
Gord
ghubbell@total.net
 
Thanks! Didn't solve the problem but I think I'm on to it now. (Your suggestion works but not in the situation I've created for myself. DoH!)
Thanks again for your help.

Mike
 
OK, I fixed what I broke, started from square one, tried your suggestion and voila! Worked great however I noticed that as I added records I was getting some really goofy numbers. I dropped the
Code:
Sum
part and all is well again so I'm assuming that
Code:
Sum
adds up the field for ALL records and then does the rest of the math?
The expression I'm using is somewhat convoluted and looks something like this:
Code:
=([UnitCost]*([Markup]+[Tax]+1))
By putting
Code:
=Sum(
etc the control bound to the UnitCost field in my table appeared to be adding the UnitCost field entries from ALL records in that table and THEN calculating the rest of the expression. Btw "Markup" and "Tax" are fields in the same table and appear in every record the same as "UnitCost".
Is this weird behaviour or can I expect this every time I use a similar expression?

Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top