Connecting Tech Pros Worldwide Forums | Help | Site Map

How to display the total of an order in a form

Newbie
 
Join Date: May 2007
Posts: 11
#1: Sep 4 '08
In an order system, there are tables of customers, products, orders, and order details, with the main fields listed as follows:

tblCostomer: CustomerID, CustomerName, ...
tblProduct: ProductID, ProductName, ...
tblOrder: OrderID, CustomerID, OrderDate, ...
tblOrderDetail: OrderID, ProductID, UnitPrice, Amount, Total, ...

I have created a query "qryTotalByOrder" which will sum up the total for each order by grouping corresponding products in that order:

qryTotalByOrder: CustomerID, OrderID, OrderDate, Total

I would like to add an unbound text box in a form " which will display the Total of a particular order by entering the orderID as a parameter. What do I need to put in the Source of Data of the textbox? Thanks.

Moderator
 
Join Date: Feb 2008
Location: Beauly, near Inverness, Scotland
Posts: 1,576
#2: Sep 4 '08

re: How to display the total of an order in a form


Hi. The domain lookup function DLookup will do this for you. Assuming the OrderID field is numeric, enter

Expand|Select|Wrap|Line Numbers
  1. =DLookup("[Totals]", "[QryTotalByOrder]", "[OrderID] = " & [YourOrderIDTextboxName])
If the order ID is a string, you will need single quotes on either side of its value:
Expand|Select|Wrap|Line Numbers
  1. =DLookup("[Totals]", "[QryTotalByOrder]", "[OrderID] = '" & [YourOrderIDTextboxName] & "'")
-Stewart
Reply